Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6404 Discussions

Can't run Classification Python Demo with OpenVINO 2022.1

Mostafa-
Employee
1,151 Views

Hello All,

 

I installed openvino-dev[caffe] successfully, and download squeesenet1.1 by;

omz_downloader --name sqeezenet1.1

 then convert it successfully by;

mo --input_model public/squeezenet1.1/squeezenet1.1.caffemodel --batch 1 --output_dir squeezenet_IR

then clone open_model_zoo to use the classification python demo;

python3 classification_demo.py -m /home/mostafa/intel/squeezenet_IR/squeezenet1.1.xml -i classification.gif --labels /home/mostafa/intel/open_model_zoo/data/dataset_classes/imagenet_2015.txt 

and I got the below error;

Traceback (most recent call last):
  File "classification_demo.py", line 28, in <module>
    from openvino.model_zoo.model_api.models import Classification, OutputTransform
ModuleNotFoundError: No module named 'openvino.model_zoo.model_api'

 Thanks,

Mostafa

0 Kudos
1 Solution
IntelSupport
Community Manager
1,044 Views

Hi Mostafa,

 

The error is because you wrongly specify the architecture_type of yolo-v4-tiny-tf model. The architecture_type of the model should be yolov4. You can refer to the Supported Models for the architecture_type of each model. I have verified the demo and the output is as below:

 

Command used :

object_detection_demo.py -i <path_to_video>\car-detection.mp4" -m "<path_to_model>\yolo-v4-tiny-tf.xml" -at yolo v4 -t 0.5 -o object_detection_output.avi

 

object_detection_demo_2022.JPG

 

 

Regards,

Aznie

 

View solution in original post

0 Kudos
6 Replies
Mostafa-
Employee
1,118 Views

I installed also openvino-dev[tensorflow2] and tried also object detection demo - python - with tiny yolov4 and I got the same error;

 

 

Traceback (most recent call last):
  File "object_detection_demo.py", line 28, in <module>
    from openvino.model_zoo.model_api.models import DetectionModel, DetectionWithLandmarks, RESIZE_TYPES, OutputTransform
ModuleNotFoundError: No module named 'openvino.model_zoo.model_api'

 

 

0 Kudos
Vladimir_Dudnik
Employee
1,086 Views

@Mostafa- starting from 2022.1 OMZ most of python demos require to install an additional module, for OMZ Model API, see documentation for more details

Installing Python* Model API package

Use the following command to install Model API from source:

pip install <omz_dir>/demos/common/python

 

0 Kudos
Mostafa-
Employee
1,058 Views

Thank You Vladimir.

 

I did it and there's another error;

 

(openvino-tensorflow_env) mostafa@mostafa-VirtualBox:~/intel/open_model_zoo/demos/object_detection_demo/python$ python3 object_detection_demo.py --model tiny-yolov4/FP32/yolo-v4-tiny-tf.xml -at yolo -i test.mp4 -t 0.5 -d CPU -o fp32_output.avi
[ INFO ] OpenVINO Runtime
[ INFO ] build: 2022.1.0-7019-cdb9bec7210-releases/2022/1
[ INFO ] Reading model tiny-yolov4/FP32/yolo-v4-tiny-tf.xml
[ WARNING ] The parameter "input_size" not found in YOLO wrapper, will be omitted
[ WARNING ] The parameter "num_classes" not found in YOLO wrapper, will be omitted
[ INFO ] Input layer: image_input, shape: [1, 416, 416, 3], precision: f32, layout: NHWC
[ INFO ] Output layer: conv2d_17/BiasAdd:0, shape: [1, 13, 13, 255], precision: f32, layout: 
[ INFO ] Output layer: conv2d_20/BiasAdd:0, shape: [1, 26, 26, 255], precision: f32, layout: 
[ INFO ] The model tiny-yolov4/FP32/yolo-v4-tiny-tf.xml is loaded to CPU
[ INFO ] Device: CPU
[ INFO ] Number of streams: 1
[ INFO ] Number of threads: AUTO
[ INFO ] Number of model infer requests: 2
Traceback (most recent call last):
  File "object_detection_demo.py", line 304, in <module>
    sys.exit(main() or 0)
  File "object_detection_demo.py", line 205, in main
    results = detector_pipeline.get_result(next_frame_id_to_show)
  File "/home/mostafa/intel/openvino-tensorflow_env/lib/python3.8/site-packages/openvino/model_zoo/model_api/pipelines/async_pipeline.py", line 124, in get_result
    result = self.model.postprocess(raw_result, preprocess_meta), {**meta, **preprocess_meta}
  File "/home/mostafa/intel/openvino-tensorflow_env/lib/python3.8/site-packages/openvino/model_zoo/model_api/models/yolo.py", line 122, in postprocess
    detections = self._parse_outputs(outputs, meta)
  File "/home/mostafa/intel/openvino-tensorflow_env/lib/python3.8/site-packages/openvino/model_zoo/model_api/models/yolo.py", line 224, in _parse_outputs
    detections += self._parse_yolo_region(out_blob, meta['resized_shape'], layer_params[1])
  File "/home/mostafa/intel/openvino-tensorflow_env/lib/python3.8/site-packages/openvino/model_zoo/model_api/models/yolo.py", line 130, in _parse_yolo_region
    predictions = permute_to_N_HWA_K(predictions, params.bbox_size, params.output_layout)
  File "/home/mostafa/intel/openvino-tensorflow_env/lib/python3.8/site-packages/openvino/model_zoo/model_api/models/yolo.py", line 44, in permute_to_N_HWA_K
    tensor = tensor.reshape(N, -1, K, H, W)
ValueError: cannot reshape array of size 43095 into shape (1,newaxis,85,13,255)

 

0 Kudos
IntelSupport
Community Manager
1,045 Views

Hi Mostafa,

 

The error is because you wrongly specify the architecture_type of yolo-v4-tiny-tf model. The architecture_type of the model should be yolov4. You can refer to the Supported Models for the architecture_type of each model. I have verified the demo and the output is as below:

 

Command used :

object_detection_demo.py -i <path_to_video>\car-detection.mp4" -m "<path_to_model>\yolo-v4-tiny-tf.xml" -at yolo v4 -t 0.5 -o object_detection_output.avi

 

object_detection_demo_2022.JPG

 

 

Regards,

Aznie

 

0 Kudos
Mostafa-
Employee
1,029 Views

thank you, it works now

0 Kudos
IntelSupport
Community Manager
1,005 Views

Hi Mostafa,


This thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question. 



Regards,

Aznie


0 Kudos
Reply