Library for simple object recognition on images using YOLO model.
Inspired by machinelearningmastery.com article by Jason Brownlee.
- as a library:
from recogn_img import read_classes, Recognizer
classes = read_classes("coco_classes.txt")
recognizer = Recognizer(model_path="yolov3.h5", classes=classes,
img_width_height=(416, 416),
threshold_box_obj=(0.5, 0.6))
results = recognizer.recognize("my_image.jpg")
print(results)
- as CLI tool (single JSON with results):
recogn-img yolov3.h5 coco_classes.txt ~/Pictures ~/RecognitionResults.json --img-width 416 --img-height 416 --box-threshold 0.5 --obj-threshold 0.6
- as CLI tool for storing images with rendered boxes in given dir:
render-recogn ~/RecognitionResults.json ~/RenderedImgs/ --copy-exif
- Linux with Python >= 3.7 installed
- CPU with AVX instruction extensions (
tensorflow>=1.5.1
requires them) - YOLO pre-trained model (weights file) converted to Keras model (.h5 file), and file with list of classes for given model, both downloaded through
make dl_model
command for your convenience - system libs (ubuntu example:
sudo apt update && sudo apt install -y libsm6 libxext6 libxrender1
)
- for development, take a look at
Makefile