backend

darknet

darknet

beagles.backend.darknet.darknet.create_darkop(ltype: str, num: int, *args)[source]

Darknet operations factory method.

Args:

ltype: layer type one of beagles.backend.darknet.darknet.darkops keys.

num: numerical index of layer

*args: variable list of layer characteristics yielded by beagles.backend.io.ConfigParser.parse_layers()

class beagles.backend.darknet.darknet.Darknet(flags)[source]
get_weight_src(flags)[source]

analyse flags.load to know where is the source binary and what is its config. can be: None, flags.model, or some other

static model_name(file_path)[source]
create_ops()[source]

return a list of layers objects (darkop.py) given path to binaries/ and configs/

load_weights()[source]

Use layers and Loader to load .weights file

class beagles.backend.darknet.darknet.Layer(*args)[source]

Parent class for all darknet layers.

load(src_loader)[source]
load_weights(src_loader)[source]
load_ckpt(src_loader)[source]
signature
varsig(var)[source]
recollect(w)[source]
present()[source]
setup(*args)[source]
finalize(*args)[source]
class beagles.backend.darknet.darknet.dropout_layer(*args)[source]
setup(p)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.connected_layer(*args)[source]
setup(input_size, output_size, activation)[source]
finalize(transpose)[source]
load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.maxpool_layer(*args)[source]
setup(ksize, stride, pad)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.shortcut_layer(*args)[source]
setup(from_layer)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.upsample_layer(*args)[source]
setup(stride, h, w)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.convolutional_layer(*args)[source]
setup(ksize, c, n, stride, pad, batch_norm, activation)[source]
finalize(_)[source]

deal with darknet

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.avgpool_layer(*args)[source]
setup()[source]

Not Implemented

finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.softmax_layer(*args)[source]
setup(groups)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.crop_layer(*args)[source]
setup()[source]

Not Implemented

finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.local_layer(*args)[source]
setup(ksize, c, n, stride, pad, w_, h_, activation)[source]
finalize(_)[source]
load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.select_layer(*args)[source]

Deprecated since version 1.0.0a1.

select and extract classes should no longer be used. Use the tf.summary API and Tensorboard to inspect network weights and biases. Use tf.saved_model API to extract graph definitions.

setup(inp, old, activation, inp_idx, out, keep, train)[source]
signature
present()[source]
recollect(val)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
varsig(var)
class beagles.backend.darknet.darknet.route_layer(*args)[source]
setup(routes)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.reorg_layer(*args)[source]
setup(stride)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
present()
recollect(w)
signature
varsig(var)
class beagles.backend.darknet.darknet.conv_select_layer(*args)[source]

Deprecated since version 1.0.0a1.

conv-select and conv-extract classes should no longer be used. Use the tf.summary API and Tensorboard to inspect network weights and biases. Use tf.saved_model API to extract graph definitions.

setup(ksize, c, n, stride, pad, batch_norm, activation, keep_idx, real_n)[source]
signature
present()[source]
recollect(w)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
varsig(var)
class beagles.backend.darknet.darknet.conv_extract_layer(*args)[source]

Deprecated since version 1.0.0a1.

conv-select and conv-extract classes should no longer be used. Use the tf.summary API and Tensorboard to inspect network weights and biases. Use tf.saved_model API to extract graph definitions.

setup(ksize, c, n, stride, pad, batch_norm, activation, inp, out)[source]
signature
present()[source]
recollect(w)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
varsig(var)
class beagles.backend.darknet.darknet.extract_layer(*args)[source]

Deprecated since version 1.0.0a1.

select and extract classes should no longer be used. Use the tf.summary API and Tensorboard to inspect network weights and biases. Use tf.saved_model API to extract graph definitions.

setup(old_inp, old_out, activation, inp, out)[source]
signature
present()[source]
recollect(val)[source]
finalize(*args)[source]

Not Implemented

load(src_loader)
load_ckpt(src_loader)
load_weights(src_loader)
varsig(var)
beagles.backend.darknet.darknet.darkops

dict: darknet layer types

Items:

‘dropout’: beagles.backend.darknet.darknet.dropout_layer

‘connected’: beagles.backend.darknet.darknet.connected_layer

‘maxpool’: beagles.backend.darknet.darknet.maxpool_layer

‘shortcut’: beagles.backend.darknet.darknet.shortcut_layer

‘upsample’: beagles.backend.darknet.darknet.upsample_layer

‘convolutional’: beagles.backend.darknet.darknet.convolutional_layer

‘avgpool’: beagles.backend.darknet.darknet.avgpool_layer

‘softmax’: beagles.backend.darknet.darknet.softmax_layer

‘crop’: beagles.backend.darknet.darknet.crop_layer

‘local’: beagles.backend.darknet.darknet.local_layer

‘select’: beagles.backend.darknet.darknet.select_layer

‘route’: beagles.backend.darknet.darknet.route_layer

‘reorg’: beagles.backend.darknet.darknet.reorg_layer

‘conv-select’: beagles.backend.darknet.darknet.conv_select_layer

‘conv-extract’: beagles.backend.darknet.darkop.conv_extract_layer

‘extract’: beagles.backend.darknet.darkop.extract_layer

io

Backend IO operations

class beagles.backend.io.ConfigParser(create_key, *args, **kwargs)[source]
classmethod create(model)[source]
class beagles.backend.io.DarknetConfigFile(path)[source]

Tokenize darknet style .cfg file to layers and metadata

to_json(**kwargs)[source]
from_json(file)[source]
tokens
beagles.backend.io.pascal_voc_clean_xml(self, annotation_dir, pick, exclusive=False)[source]

Parses PASCAL VOC XML annotations

net

Top-level module for machine-learning backend

class beagles.backend.net.Net(layers: list, step, **kwargs)[source]

A simple model. Args:

layers: list of beagles.backend.darknet.darknet.Darknet layers step: scalar holding current step
train_step(data)[source]

The logic for one training step.

This method can be overridden to support custom training logic. This method is called by Model.make_train_function.

This method should contain the mathemetical logic for one step of training. This typically includes the forward pass, loss calculation, backpropagation, and metric updates.

Configuration details for how this logic is run (e.g. tf.function and tf.distribute.Strategy settings), should be left to Model.make_train_function, which can also be overridden.

Arguments:
data: A nested structure of `Tensor`s.
Returns:
A dict containing values that will be passed to tf.keras.callbacks.CallbackList.on_train_batch_end. Typically, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.
call(x, training=False, **loss_feed)[source]

Calls the model on new inputs.

In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).

Arguments:

inputs: A tensor or list of tensors. training: Boolean or boolean scalar tensor, indicating whether to run

the Network in training mode or inference mode.
mask: A mask or list of masks. A mask can be
either a tensor or None (no mask).
Returns:
A tensor if there is a single output, or a list of tensors if there are more than one outputs.
class beagles.backend.net.NetBuilder(flags, darknet=None)[source]

Initializes with flags that build a Darknet or with a prebuilt Darknet. Constructs the actual Net object upon being called.

build_optimizer()[source]
compile_darknet()[source]
load_checkpoint(manager)[source]
beagles.backend.net.train(data, class_weights, flags, net: beagles.backend.net.Net, framework: beagles.backend.net.framework.Framework, manager: tensorflow.python.training.checkpoint_management.CheckpointManager)[source]
beagles.backend.net.predict(flags, net: beagles.backend.net.Net, framework: beagles.backend.net.framework.Framework)[source]
beagles.backend.net.annotate(flags, net, framework)[source]

hyperparameters

beagles.backend.net.hyperparameters.cyclic_learning_rate[source]

Applies cyclic learning rate (CLR). From the paper:

Smith, Leslie N. “Cyclical learning rates for training neural networks.” 2017. Link

This method lets the learning rate cyclically vary between reasonable boundary values achieving improved classification accuracy and often in fewer iterations. This code varies the learning rate linearly between the minimum (learning_rate) and the maximum (max_lr).

It returns the cyclic learning rate. It is computed as:

\[\begin{equation} \text{learning_rate} + (\text{max_lr} - \text{learning_rate})\cdot\max\left(1 - \bigg|\frac{\text{global_step}}{\text{step_size} - 2 \cdot \lfloor\frac{1 + \text{global_step}}{2\cdot\text{step_size}}\rfloor}\bigg| \right) \end{equation}\]

Pseudocode:

cycle = floor( 1 + global_step / ( 2 * step_size ) )
x = abs( global_step / step_size – 2 * cycle + 1 )
clr = learning_rate + ( max_lr – learning_rate ) * max( 0 , 1 - x )
Note:
When eager execution is enabled, this function returns a function which in turn returns the decayed learning rate Tensor. This can be useful for changing the learning rate value across different invocations of self.optimizer functions.
Polices:
‘triangular’:
Default, linearly increasing then linearly decreasing the learning rate at each cycle.
‘triangular2’:
The same as the triangular policy except the learning rate difference is cut in half at the end of each cycle. This means the learning rate difference drops after each cycle.
‘exp_range’:
The learning rate varies between the minimum and maximum boundaries and each boundary value declines by an exponential factor of: gamma^global_step.
Example: ‘triangular2’ mode cyclic learning rate.
...
global_step = tf.Variable(0, trainable=False)
self.optimizer = tf.train.AdamOptimizer(learning_rate=clr.cyclic_learning_rate(global_step=global_step, mode='triangular2'))
train_op = self.optimizer.minimize(loss_op, global_step=global_step)
...
with tf.Session() as sess:
    sess.run(init)
    for step in range(1, num_steps+1):
      assign_op = global_step.assign(step)
      sess.run(assign_op)
...
Args:
global_step: A scalar int32 or int64 Tensor or a Python number.
Global step to use for the cyclic computation. Must not be negative.
learning_rate: A scalar float32 or float64 Tensor or a Python number.
The initial learning rate which is the lower bound of the cycle (default = 0.1).
max_lr: A scalar.
The maximum learning rate boundary.
step_size: A scalar. The number of iterations in half a cycle.
The paper suggests step_size = 2-8 x training iterations in epoch.
gamma: constant in ‘exp_range’ mode:
gamma**(global_step)
mode: one of {triangular, triangular2, exp_range}.
Default ‘triangular’. Values correspond to policies detailed above.
name: String. Optional name of the operation. Defaults to
‘CyclicLearningRate’.
Returns:
A scalar Tensor of the same type as learning_rate. The cyclic learning rate.
Raises:
ValueError: if global_step is not supplied.

framework

class beagles.backend.net.framework.Framework(create_key, *args, **kwargs)[source]

SubsystemPrototype that uses Darknet configuration metadata type token to find a framework

class beagles.backend.net.framework.NeuralNet(create_key, *args, **kwargs)[source]
class beagles.backend.net.framework.Yolo(create_key, *args, **kwargs)[source]
postprocess(net_out, im: os.PathLike, save: bool = True) → numpy.ndarray
Takes net output, draw predictions, saves to disk
turns ProcessedBox into PostprocessedBox
Args:

net_out: A single fetch from tf session.run.

im: A path or pathlike object to an image file.

save: Whether to save predictions to disk defaults to True.

Returns:
imgcv: An annotated np.ndarray if save == False or None if save == True
loss(net_out)

Takes net.out and placeholders value returned in batch() func above, to build train_op and loss

is_input(name)

checks if input has a valid image file extension

batch(chunk)

Takes a chunk of parsed annotations returns value for placeholders of net’s input & loss layer correspond to this chunk

preprocess(image: Union[numpy.ndarray, Any], allobj: List[T] = None) → numpy.ndarray

Takes an image, return it as a numpy tensor that is readily to be fed into tfnet.

Note:
If there is an accompanied annotation (allobj), meaning this preprocessing is being used for training, then this image will be transformed with random noise to augment training data, using scale, translation, flipping and recolor.
Args:

image: An np.ndarray or file-like image object.

allobj: List of annotated objects.

Returns:
image: A randomly transformed and recolored np.ndarray
class beagles.backend.net.framework.YoloV2(create_key, *args, **kwargs)[source]
postprocess(net_out, im: os.PathLike, save: bool = True) → numpy.ndarray
Takes net output, draw predictions, saves to disk
turns ProcessedBox into PostprocessedBox
Args:

net_out: A single fetch from tf session.run.

im: A path or pathlike object to an image file.

save: Whether to save predictions to disk defaults to True.

Returns:
imgcv: An annotated np.ndarray if save == False or None if save == True
loss

Takes net.out and placeholders value returned in batch() func above, to build train_op and loss

is_input(name)

checks if input has a valid image file extension

batch(chunk)

Takes a chunk of parsed annotations returns value for placeholders of net’s input & loss layer correspond to this chunk

preprocess(image: Union[numpy.ndarray, Any], allobj: List[T] = None) → numpy.ndarray

Takes an image, return it as a numpy tensor that is readily to be fed into tfnet.

Note:
If there is an accompanied annotation (allobj), meaning this preprocessing is being used for training, then this image will be transformed with random noise to augment training data, using scale, translation, flipping and recolor.
Args:

image: An np.ndarray or file-like image object.

allobj: List of annotated objects.

Returns:
image: A randomly transformed and recolored np.ndarray

tfnet

:members:

base

Base classes and methods for other BEAGLES modules

class beagles.base.PreprocessedBox[source]

Holds a box returned from a cython box constructor

x

Alias for field number 0

y

Alias for field number 1

w

Alias for field number 2

h

Alias for field number 3

c

Alias for field number 4

probs

Alias for field number 5

class beagles.base.ProcessedBox[source]

Holds a box returned by a backend framework’s process_box and findboxes methods.

left

Alias for field number 0

right

Alias for field number 1

top

Alias for field number 2

bot

Alias for field number 3

label

Alias for field number 4

max_idx

Alias for field number 5

max_prob

Alias for field number 6

class beagles.base.PostprocessedBox[source]

Holds labeled bounding box returned by framework’s postprocess method.

xmin

Alias for field number 0

ymin

Alias for field number 1

xmax

Alias for field number 2

ymax

Alias for field number 3

label

Alias for field number 4

difficult

Alias for field number 5

class beagles.base.Flags(defaults=True)[source]

Allows you to set and get {key: value} pairs like attributes. Enforces type-checking during flag setting. This allows compatibility with argparse.Namespace objects.

from_json(file)[source]
to_json(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
class beagles.base.Shape(label=None, line_color=None, difficult=False, paintLabel=False)[source]
P_SQUARE = 0
P_ROUND = 1
MOVE_VERTEX = 0
NEAR_VERTEX = 1
fill_color = <PyQt5.QtGui.QColor object>
select_line_color = <PyQt5.QtGui.QColor object>
select_fill_color = <PyQt5.QtGui.QColor object>
vertex_fill_color = <PyQt5.QtGui.QColor object>
hvertex_fill_color = <PyQt5.QtGui.QColor object>
point_type = 1
point_size = 8
scale = 1.0
line_color = <PyQt5.QtGui.QColor object>
close()[source]
reachMaxPoints()[source]
addPoint(point)[source]
popPoint()[source]
isClosed()[source]
setOpen()[source]
paint(painter)[source]
drawVertex(path, i)[source]
nearestVertex(point, epsilon)[source]
containsPoint(point)[source]
makePath()[source]
boundingRect()[source]
moveBy(offset)[source]
moveVertexBy(i, offset)[source]
highlightVertex(i, action)[source]
highlightClear()[source]
copy()[source]
class beagles.base.Timer[source]
class beagles.base.StringBundle(create_key, localeStr)[source]
classmethod getBundle(localeStr=None)[source]
getString(stringId)[source]
beagles.base.getStr(strId: str) → str[source]

Convenience function to grab strings from StringBundle

Args:
strId: resource ID for the string to get
Returns:
str matching the resource ID
class beagles.base.Subsystem[source]
constructor(*args, **kwargs)[source]
class beagles.base.SubsystemPrototype(create_key, *args, **kwargs)[source]
create_key = <object object>
classmethod get_register() → dict[source]
classmethod create(*args)[source]
beagles.base.register_subsystem(token: Union[AnyStr, List[T]], prototype: Type[beagles.base.SubsystemPrototype]) → Callable[source]

Decorator to register Subsystem metadata tokens to a SubsystemPrototype

Example:

Can be used with a single text token…

@register_subsystem(token='[detection]', prototype=Framework)
class Yolo(Subsystem):
...
>>> Yolo.token
{'[detection]': Yolo}

Or can be be used with multiple token splitting on space…

@register_subsystem(token='sse l1 l2 smooth sparse softmax', prototype=Framework)
class NeuralNet(Subsystem):
    ...
>>> NeuralNet.token
{'sse': NeuralNet, l1: NeuralNet, l2: NeuralNet, ...}
Returns:
A registered Subsystem with Subsystem.token set to {cls: token} and it’s __mro__ overridden with prototype.
Raises:
TypeError: If Subsystem or SubsystemPrototype isn’t in the registered class MRO

io

class beagles.io.SharedMemory[source]

Stateful interface for shared memory on mac or linux

path

str: Path to the shared memory drive.

info

dict: Info about the shared memory drive.

mounted

bool: True if the shared memory drive is mounted otherwise false.

mount()[source]

Mounts a shared memory drive using RAMDisk mount if MacOS otherwise no operation.

unmount()[source]

Unmounts a shared memory drive using RAMDisk unmount if MacOS otherwise no operation.

class beagles.io.TiledCaptureArray(num_divisions: int, video: os.PathLike, unused_cameras: List[int])[source]

Object definition for tiled capture arrays.

Args:

num_divisions: number of tiles to process

video: path to source video

unused_cameras: camera sources to skip during processing.

Note:
Cameras are numbered as follows: \(\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}\)
crop()[source]

Stream copies processed tiles to labeled files using ffmpeg

class beagles.io.LabelFile(filename=None)[source]
suffix = '.xml'
savePascalVocFormat(filename, shapes, imagePath, imageData, lineColor=None, fillColor=None, databaseSrc=None)[source]
saveYoloFormat(filename, shapes, imagePath, imageData, classList, lineColor=None, fillColor=None, databaseSrc=None)[source]
toggleVerify()[source]
static isLabelFile(filename)[source]
convertPoints2BndBox(points, label, difficult)[source]
class beagles.io.YoloReader(filepath, image, classListPath=None)[source]
getShapes()[source]
addShape(label, xmin, ymin, xmax, ymax, difficult)[source]
yoloLine2Shape(classIndex, xcen, ycen, w, h)[source]
parseYoloFormat()[source]
class beagles.io.YoloWriter(foldername, filename, imgSize, databaseSrc='Unknown', localImgPath=None)[source]
BndBox2YoloLine(box, classList: list)[source]
save(classList: list, targetFile=None)[source]
class beagles.io.PascalVocReader(filepath)[source]
getShapes()[source]
addShape(label, bndbox, difficult)[source]
parseXML()[source]
class beagles.io.PascalVocWriter(foldername, filename, imgSize, databaseSrc='Unknown')[source]
prettify(elem)[source]

Return a pretty-printed XML string for the Element.

genXML()[source]

Return XML root

appendObjects(top)[source]
save(targetFile=None)[source]
class beagles.io.Settings[source]
trans_reverse = {"<class 'PyQt5.QtCore.QByteArray'>": <class 'PyQt5.QtCore.QByteArray'>, "<class 'PyQt5.QtCore.QPoint'>": <class 'PyQt5.QtCore.QPoint'>, "<class 'PyQt5.QtCore.QSize'>": <class 'PyQt5.QtCore.QSize'>, "<class 'PyQt5.QtGui.QColor'>": <class 'PyQt5.QtGui.QColor'>}
get(key, default=None)[source]
save()[source]
load()[source]
reset()[source]
beagles.io.get_logger(level=20)[source]

Convenience function to get a logging.Logger

Args:
level (int): One of logging.FATAL, logging.ERROR, logging.WARN, logging.INFO, or logging.DEBUG.
Return:
logging.Logger with logging level set to level
beagles.io.datetime_from_filename(filename: Union[AnyStr, os.PathLike], fmt: str = 'underscore')[source]

Convenience function to get datetime.strptime from filenames containing ISO 8601 timestamps.

Extracts a datetime object from OBS Video Filename containing %CCYY-%MM-%DD %hh-%mm-%ss or %CCYY-%MM-%DD_%hh-%mm-%ss.

Args:
filename: File to extract datetime from. fmt: Format to return strptime in one of ‘underscore’ or ‘space’
Returns:
A strptime string containing the datetime extracted from filename

resources

Files to bundle into compiled resources using pyrcc5 from the Qt resource system.

resources.qrc

Manifest of all resource files to bundle. Icons are aliased to action names and strings are aliased as their file basename.

<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<!-- resource and locale-specific resource paths -->
<file alias="showInfo">icons/help.png</file>
<file alias="showTutorialDialog">icons/help.png</file>
<file alias="app">icons/app.png</file>
<file alias="advancedMode">icons/expert2.png</file>
<file alias="done">icons/done.png</file>
<file alias="file">icons/file.png</file>
<file alias="labels">icons/labels.png</file>
<file alias="setCreateMode">icons/objects.png</file>
<file alias="createShape">icons/objects.png</file>
<file alias="close">icons/close.png</file>
<file alias="setFitWidth">icons/fit-width.png</file>
<file alias="setFitWin">icons/fit-window.png</file>
<file alias="undo">icons/undo.png</file>
<file alias="hideAll">icons/eye.png</file>
<file alias="showAll">icons/eye.png</file>
<file alias="close">icons/quit.png</file>
<file alias="closeFile">icons/quit.png</file>
<file alias="copySelectedShape">icons/copy.png</file>
<file alias="setEditMode">icons/edit.png</file>
<file alias="editLabel">icons/edit.png</file>
<file alias="openFile">icons/openFile.png</file>
<file alias="openDir">icons/open.png</file>
<file alias="changeSaveDir">icons/changeSaveDir.png</file>
<file alias="openAnnotation">icons/openAnnotation.png</file>
<file alias="impVideo">icons/impvideo.png</file>
<file alias="switchmeon">icons/switchmeon.png</file>
<file alias="switchmeoff">icons/switchmeoff.png</file>
<file alias="trainModel">icons/trainModel.png</file>
<file alias="visualize">icons/visualize.png</file>
<file alias="commitAnnotatedFrames">icons/commitAnnotatedFrames.png</file>
<file alias="frameByFrame">icons/frameByFrame.png</file>
<file alias="demoWebcam">icons/demoWebcam.png</file>
<file alias="saveFile">icons/save.png</file>
<file alias="changeFormat">icons/format_voc.png</file>
<file alias="format_voc">icons/format_voc.png</file>
<file alias="format_yolo">icons/format_yolo.png</file>
<file alias="saveAs">icons/save-as.png</file>
<file alias="shapeFillColor">icons/color.png</file>
<file alias="boxLineColor">icons/color_line.png</file>
<file alias="shapeLineColor">icons/color_line.png</file>
<file alias="zoomOrg">icons/zoom.png</file>
<file alias="zoomIn">icons/zoom-in.png</file>
<file alias="zoomOut">icons/zoom-out.png</file>
<file alias="delBox">icons/cancel.png</file>
<file alias="nextImg">icons/next.png</file>
<file alias="prevImg">icons/prev.png</file>
<file alias="resetAll">icons/resetall.png</file>
<file alias="verifyImg">icons/verify.png</file>
<file alias="strings">strings/strings.properties</file>
<file alias="strings-zh-TW">strings/strings-zh-TW.properties</file>
<file alias="strings-zh-CN">strings/strings-zh-CN.properties</file>
<file alias="strings-te-IN">strings/strings-te-IN.properties</file>
<file alias="strings-ru-RU">strings/strings-ru-RU.properties</file>
<file alias="strings-pt-BZ">strings/strings-pt-BZ.properties</file>
<file alias="strings-ja-JP">strings/strings-ja-JP.properties</file>
<file alias="strings-hi-IN">strings/strings-hi-IN.properties</file>
<file alias="strings-es-MX">strings/strings-es-MX.properties</file>
<file alias="strings-bn-IN">strings/strings-bn-IN.properties</file>
</qresource>
</RCC>

actions

Each action will have an entry in actions.json, an entry of the same name for the main string strings.properties, and an entry in resources.qrc that points to the icon for the action contained in resources/icons.

actions.json

Serialized partial arguments for the beagles.ui.newAction() constructor, each entry contains a keyboard shortcut, a boolean whether the action is enabled, and a boolean whether the action is checkable.

{
   "openFile":["Ctrl+o", false, true],
   "openDir": ["Ctrl+u", false, true],
   "impVideo":["Ctrl+i", false, true],
   "changeSaveDir":["Ctrl+r", false, true],
   "openAnnotation":["Ctrl+Shift+o", false, true],
   "nextImg":["d", false, true],
   "prevImg":["a", false, true],
   "verifyImg":["space", false, true],
   "saveFile":["Ctrl+s", false, false],
   "changeFormat":[null, false, true],
   "saveAs":["Ctrl+Shift+s", false, false],
   "closeFile":["Ctrl+w", false, true],
   "resetAll":[null, false, true],
   "boxLineColor":["Ctrl+l", false, true],
   "setCreateMode":["w", false, false],
   "createShape":["w", false, false],
   "setEditMode":["e", false, false],
   "commitAnnotatedFrames":[null, false, true],
   "visualize":[null, false, true],
   "hideAll":["Ctrl+h", false, false],
   "showAll":["Ctrl+a", false, false],
   "trainModel":["Ctrl+t", false, true],
   "delBox":["Delete", false, false],
   "advancedMode":["Ctrl+Shift+a", true, true],
   "showInfo":[null, false, true],
   "showTutorialDialog":[null, false, true],
   "close":["Ctrl+q", false, true],
   "zoomIn":["Ctrl++", false, false],
   "zoomOut":["Ctrl+-", false, false],
   "zoomOrg":["Ctrl+Shift++", false, false],
   "setFitWin":["Ctrl+f", true, false],
   "setFitWidth":["Ctrl+Shift+f", true, false],
   "editLabel":["Ctrl+e", false, false],
   "shapeFillColor": [null, false, false],
   "shapeLineColor":[null, false, false],
   "copySelectedShape":["Ctrl+d", false, false]
}

strings

String resources and localized translations for Qt

strings.properties

openFile=Open
openFileDetail=Open image or label file
close=Quit
closeDetail=Quit Application
openDir=Open Folder
openDirDetail=Open Folder
impVideo=Import Video Frames
impVideoDetail=Import raw video frames for annotation
commitAnnotatedFrames=Commit Annotations
commitAnnotatedFramesDetail=Dump annotated frames into the data folder
trainModel=Train a Model
trainModelDetail=Choose a model to train on the data folder
visualize=Visualize Model
visualizeDetail=Visualize model using tensorboard
frameByFrame=Annotate a Video
frameByFrameDetail=Choose a video file to annotate frame by frame
demoWebcam=Demo Model on Webcam
demoWebcamDetail=Demonstrate the model using a webcam
changeSaveDirDetail=Change default saved Annotation dir
openAnnotation=Open Annotation
openAnnotationDetail=Open an annotation file
changeSaveDir=Change Save Folder
nextImg=Next Image
nextImgDetail=Open the next Image
prevImg=Prev Image
prevImgDetail=Open the previous Image
verifyImg=Verify Image
verifyImgDetail=Verify Image
saveFile=Save
train=Train
predict=Predict
annotate=Annotate
analyze=Analyze
selectProject=Select Project
projectLayout=Project Name
flowCmb=Mode
modelCmb=Model
loadCmb=Checkpoint
thresholdSpd=Threshold
verbaliseChb=Verbose
jsonChb=Output JSON Annotations
vocChb=Output VOC Annotations
trainerCmb=Training Algorithm
momentumSpd=Momentum
learningModeCmb=Learning Mode
learningRateSpd=Initial Learning Rate
maxLearningRateSpd=Maximum Learning Rate
stepSizeCoefficient=Step Size Coefficient
keepSpb=Checkpoints to Keep
batchSpb=Batch Size
epochSpb=Epochs to Run
saveSpb=Save Every
clipLayout=Clip Gradients
updateAnchorChb=Update Anchors
triangularTip=By default, the learning rate increases linearly in each cycle and then decreases linearly.
triangular2Tip=The same as the triangular policy except the learning rate difference is cut in half at the end of each cycle. This means the learning rate difference drops after each cycle.
exp_rangeTip=The learning rate varies between the minimum and maximum boundaries, and the exponential factor for each boundary value drop is: γ^global_step
momentumTip=Momentum setting for momentum and rmsprop optimizer
saveFileDetail=Save the labels to a file
changeFormatDetail=Change save format
saveAs=Save As
saveAsDetail=Save the labels to a different file
closeFile=Close
closeFileDetail=Close the current file
resetAll=Reset All
resetAllDetail=Reset All
boxLineColor=Box Line Color
boxLineColorDetail=Choose Box line color
createShape=Create Box
createShapeDetail=Draw a new box
setCreateMode=Create Box
setCreateModeDetail=Draw a new box
delBox=Delete Box
delBoxDetail=Remove the box
copySelectedShape=Duplicate Box
copySelectedShapeDetail=Create a duplicate of the selected box
showTutorialDialog=Tutorial
showTutorialDialogDetail=Show demo
showInfo=Information
showInfoDetail=App Information
zoomIn=Zoom In
zoomInDetail=Increase zoom level
zoomOut=Zoom Out
zoomOutDetail=Decrease zoom level
zoomOrg=Original size
zoomOrgDetail=Zoom to original size
setFitWin=Fit Window
setFitWinDetail=Zoom follows window size
setFitWidth=Fit Widith
setFitWidthDetail=Zoom follows window width
editLabel=Edit Label
editLabelDetail=Modify the label of the selected Box
shapeLineColor=Shape Line Color
shapeLineColorDetail=Change the line color for this specific shape
shapeFillColor=Shape Fill Color
shapeFillColorDetail=Change the fill color for this specific shape
showHide=Show/Hide Label Panel
useDefaultLabel=Use default label
useDifficult=difficult
boxLabelText=Box Labels
labels=Labels
autoSaveMode=Auto Save mode
singleClsMode=Single Class Mode
displayLabel=Display Labels
fileList=File List
files=Files
advancedMode=Advanced Mode
advancedModeDetail=Swtich to advanced mode
showAllDetail=Show all bounding boxes
showAll=Show Bounding Box
hideAllDetail=Hide all bounding boxes
hideAll=Hide Bounding Box
changeFormat=&PascalVOC
setEditMode=Edit Box
setEditModeDetail=Move and edit boxes

scripts

RAMDisk

MacOS-specific tool used by beagles.io.SharedMemory to create a shared memory drive.

#! /bin/sh
NAME="$(basename $0)"
VOLUMEPATH="/Volumes"
if [ "$(uname)" != "Darwin" ]; then
    >&2 echo Error: $0 script is only designed to be run on macOS
    exit 1
fi

RAMDisk_mount() {
    if [ ! -d "$VOLUMEPATH/$NAME" ]; then
        diskutil eraseVolume HFS+ $NAME `hdiutil attach -nomount ram://$((2048 * 2))`
      exit
    else

        exit 1
    fi
}

RAMDisk_unmount() {
    while true
    do
        CURDISK=$(diskutil info $NAME | grep -o '/dev/disk[1-99]')
        if [ "$CURDISK" = "" ]; then
            >&2 echo $NAME not mounted in $VOLUMEPATH
            exit 1
        else
            echo "$1 $NAME @ $CURDISK"
            hdiutil detach $CURDISK
        fi
    done
}

eval ${NAME}_${1} ${1}
#if [[ "$1" = "mount" ]]; then
#    RAMDisk_mount
#elif [[ "$1" = "unmount" ]]; then
#    RAMDisk_unmount
#else
#    >&2 echo "line $LINENO: $NAME_$1: command not found"
#fi

ui

class beagles.ui.Struct(**kwargs)[source]
__init__(**kwargs)[source]

Updates self.__dict__ with **kwargs.

__ior__(other)[source]

Merges self.__dict__ and other.__dict__ using the | operator

beagles.ui.newIcon(icon: str)[source]
beagles.ui.newButton(text: str, icon: str = None, slot=None)[source]
beagles.ui.newAction(parent, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False, enabled=True)[source]

Create a new action and assign callbacks, shortcuts, etc.

beagles.ui.addActions(widget, actions)[source]
beagles.ui.distance(p: PyQt5.QtCore.QPointF) → float[source]
Returns:
Distance from the origin (0,0).

callbacks

Action callbacks for menu/toolbar actions defined in actions.json

functions

Dependency methods for beagles.ui.callbacks

widgets

QWidget children used the BEAGLES UI