tests package

Submodules

tests.helper module

class Timer[source]

Bases: object

Helper class to measure inference time.

Example:
>>> import time
>>> timer = Timer()
>>> with timer:
>>>     time.sleep(1)
>>> print(timer.results[0])
build_tf_model_from_file(filename)[source]

Method to create tflite model from file

Parameters

filename – tflite model file

Returns

interpreted tflite model

evaluate_q_model_from_file(tf_lite_model, test_images)[source]

Creates and evaluates a tflite model

Parameters
  • tf_lite_model – a tflite model file

  • test_images – input to evaluate

Returns

prediction of the model

tests.test_tf_architectures module

Inference tests using originally trained models

tests.test_tf_lite_architectures module

Inference tests using TFLite models

tests.test_yolo_inference module

Inference tests using weights of pretrained YOLOv5

filter_classes(classes_in)[source]

transforms one-hot-encoded prediction into class indices

Parameters

classes_in – one-hot-encoded predictions

Returns

converted labels

process_best_prediction(prediction)[source]

Select best prediction for each sample

Parameters

prediction – iterable holding performed predictions

Returns

The best prediction for each input sample

scale_bb(bb, h, w)[source]

Scales percentage BB into real sized BB.

Parameters
  • bb – the bb to scale

  • h – image width

  • w – image height

Returns

scaled BBox

yolo2voc(bboxes)[source]

Converts yolo output to VOC format

yolo => [xmid, ymid, w, h] (normalized) voc => [x1, y1, x2, y1]

Parameters

bboxes – bounding boxes to convert

Returns

converted bboxes