ultrayolo.helpers package

Submodules

ultrayolo.helpers.callbacks module

ultrayolo.helpers.callbacks.default_callbacks(model, run_path, lrate_mode, lrate_value, verbose=1)[source]

create the callbacks for the model

Arguments:

model {tf.keras.Model} – a valid tensorflow model run_path {str} – the path to save the checkpoints lrate_mode {str} – the mode for the learning rate scheduler

(values: cyclic, exp_range, reduce_on_plateau)

lrate_value {float} – the initial value for the learning rate verbose {int} – 0 for no verbose, 1 for verbose (default: 1)

Returns:

list – a list of tf.keras.callbacks

ultrayolo.helpers.callbacks.lr_scheduler(lrate_mode, lrate_value, verbose=1)[source]
ultrayolo.helpers.callbacks.save_model(model, checkpoints_path)[source]

method to save the model

Arguments:

model {tf.keras.Model} – the model to save checkpoints_path {str} – the path to save the chckpoints

Returns:

[tf.keras.callbacks.LambdaCallback]

ultrayolo.helpers.darknet module

ultrayolo.helpers.darknet.freeze(model)[source]
ultrayolo.helpers.darknet.freeze_backbone(model)[source]
ultrayolo.helpers.darknet.freeze_backbone_layers(model, num_layers)[source]

model: a yolo model num_layers: the number of layers starting from the last layer of darknet to freeze

ultrayolo.helpers.darknet.load_darknet_weights(model, weights_file, tiny=False, for_transfer=False, debug=False)[source]
ultrayolo.helpers.darknet.set_trainable(layer, value)[source]
ultrayolo.helpers.darknet.unfreeze(model)[source]

ultrayolo.helpers.draw module

ultrayolo.helpers.draw.boundingbox_height(box)[source]
ultrayolo.helpers.draw.boundingbox_width(box)[source]
ultrayolo.helpers.draw.get_cell_responsible_on_grid(box_xywh, img_size, grid_len)[source]

Computes the grid cell responsible to detect the box

ultrayolo.helpers.draw.grid(ax, target_shape, grid_len)[source]
ultrayolo.helpers.draw.outline(o, lw)[source]
ultrayolo.helpers.draw.point(ax, xy, color='red')[source]
ultrayolo.helpers.draw.rect(ax, b, color='#9cff1d', lw=4)[source]

ax: the axis to plot b: a bounding box of type (x_min, y_min, x_max, y_max)

ultrayolo.helpers.draw.show_img(im, figsize=None, ax=None)[source]
ultrayolo.helpers.draw.text(ax, xy, txt, sz=14)[source]

Module contents

ultrayolo.helpers.create_run_path(checkpoints_path)[source]

create the run path to save the checkpoints of the model

Arguments:

checkpoints_path {str} – the path to save the checkpoints

Returns:

Path – the path to save the checkpoints

ultrayolo.helpers.unfreeze_checkpoint(path)[source]

fix an issue in tensorflow that not allow you to reload checkpoints where some layers are freezed

Arguments:

path {pathlib.Path} – the path to the h5 file