Image Classification Example
Примеры с cv2.imshow требуют сборки OpenCV с GUI. В ноутбуке с headless-версией используйте вывод изображений через Matplotlib.
Image Classification Example
|
|
| 3 |
|---|
|
canvasInput
|
|
modelFile
|
|
configFile
|
1.The parameters for model inference which you can modify to investigate more models.
2.Main loop in which will read the image from canvas and do inference once.
3.Load labels from txt file and process it into an array.
4.Get blob from image as input for net, and standardize it with mean and std.
5.Fetch model file and save to emscripten file system once click the input button.
6.The post-processing, including softmax if needed and get the top classes from the output vector.
Static OpenCV.js code sample extracted from the pinned documentation source:
inputSize = [224,224];
mean = [104, 117, 123];
std = 1;
swapRB = false;
// record if need softmax function for post-processing
needSoftmax = false;
// url for label file, can from local or Internet
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/4.x/samples/data/dnn/classification_classes_ILSVRC2012.txt";