ml.cv
#
Description#
Plugin to train and make computer vision predictions using machine learning models.
Also make sure that your OpenCV installation comes with the dnn
module. To test it:
>>> import cv2.dnn
Configuration#
ml.cv:
# No configuration required
Dependencies#
pip
pip install opencv-python numpy
Alpine
apk add py3-opencv py3-numpy
Debian
apt install python3-opencv python3-numpy
Fedora
yum install python-opencv python-numpy
Arch Linux
pacman -S python-opencv python-numpy
Actions#
Module reference#
- class platypush.plugins.ml.cv.MlCvPlugin(**kwargs)[source]#
Bases:
Plugin
Plugin to train and make computer vision predictions using machine learning models.
Also make sure that your OpenCV installation comes with the
dnn
module. To test it:>>> import cv2.dnn
- predict(img, model_file, classes=None, resize=None, color_convert=None)[source]#
Make predictions for an input image using a model file. Supported model formats include all the types supported by cv2.dnn (currently supported: Caffe, TensorFlow, Torch, Darknet, DLDT).
- Parameters:
model_file – Path to the model file
img – Path to the image
classes – List of string labels associated with the output values (e.g. [‘negative’, ‘positive’]). If not set then the index of the output neuron with highest value will be returned.
resize – Tuple or list with the resize factor to be applied to the image before being fed to the model (default: None)
color_convert – Color conversion to be applied to the image before being fed to the model. It points to a cv2 color conversion constant (e.g.
cv2.COLOR_BGR2GRAY
) and it can be either the constant value itself or a string (e.g. ‘COLOR_BGR2GRAY’).