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.
6441 Discussions

Error: The input tensor size is not equal to the model input type

YogeshTyagi
Employee
229 Views

I was trying to run a classification sample with openvino:

python3 classification_sample_async.py -m public/googlenet-v3/FP32/googlenet-v3.xml -i banana.jpg -d GPU

and getting this error:

super().start_async(
RuntimeError: Exception from src/inference/src/cpp/infer_request.cpp:235:
Check 'is_dynamic || port.get_shape() == tensor->get_shape()' failed at src/inference/src/dev/isync_infer_request.cpp:277:
The input tensor size is not equal to the model input type: got [1,299,3,3] expecting [1,299,3,299].


I got the model in follwoing way:

omz_downloader --name googlenet-v3

omz_converter --name googlenet-v3

I am using openvino 2024.2.0 on Ubuntu 22.04

0 Kudos
1 Solution
Peh_Intel
Moderator
67 Views

Hi YogeshTyagi,


For your information, I am able to run Classification Python demo without having any import issue by running the demo in the directory, where the classification_demo.py script located.


e.g.

cd ~/Downloads/open_model_zoo/demos/classification_demo/python

 

python3 classification_demo.py -m googlenet-v3.xml -i image.jpg -d GPU


OR


python3 ~/Downloads/open_model_zoo/demos/classification_demo/python/classification_demo.py -m googlenet-v3.xml -i image.jpg -d GPU


You can have a look at the Line 26 and 27 of classification_demo.py script. The line 26 defines the path of the monitors.py script while the line 27 defines the path of the model_zoo folder.



Regards,

Peh


View solution in original post

3 Replies
Peh_Intel
Moderator
187 Views

Hi YogeshTyagi,

 

For your information, OpenVINO Image Classification Async Python Sample only validated with alexnet model. Since alexnet model is only available in OMZ 2023.3, you can download the alexnet model through the link below for your ease.

 https://drive.google.com/drive/folders/1oiazRFPMVvQPseZxkR0-7kPmapWGTF_k?usp=sharing

 

To run classification demo with googlenet-v3 model, please use Classification Python Demo that available in open_model_zoo GitHub repository.

 

 

Regards,

Peh

 

0 Kudos
YogeshTyagi
Employee
178 Views

Thanks, Peh.

 

I used googlenet-v3 model with Classification Python demo that you suggested. I installed openvino-model-api as well.

 

git clone https://github.com/openvinotoolkit/open_model_zoo.git
cd open_model_zoo/
git checkout 2024.2.0
cd ..
pip install open_model_zoo/demos/common/python

 

But got following error when running the sample:

 

python3 classification_demo.py -m public/googlenet-v3/FP32/googlenet-v3.xml -i banana.jpg -d GPU

 

ImportError: cannot import name 'Classification' from 'model_api.models'

 

I had to change following imports in classification_demo.py.

From this:

from model_api.models import Classification, OutputTransform
from model_api.performance_metrics import put_highlighted_text, PerformanceMetrics
from model_api.pipelines import get_user_config, AsyncPipeline
from model_api.adapters import create_core, OpenvinoAdapter, OVMSAdapter

 

To this:

from model_zoo.model_api.models import Classification, OutputTransform
from model_zoo.model_api.performance_metrics import put_highlighted_text, PerformanceMetrics
from model_zoo.model_api.pipelines import get_user_config, AsyncPipeline
from model_zoo.model_api.adapters import create_core, OpenvinoAdapter, OVMSAdapter


After that I got the error "No module named 'monitors'"

I had to "cd open_model_zoo/demos/common/python"

and run classification_demo.py from this path (because monitors.py exists at this path)

 

I did not expect to make such changes to run a sample app. Am I doing something wrong here?

0 Kudos
Peh_Intel
Moderator
68 Views

Hi YogeshTyagi,


For your information, I am able to run Classification Python demo without having any import issue by running the demo in the directory, where the classification_demo.py script located.


e.g.

cd ~/Downloads/open_model_zoo/demos/classification_demo/python

 

python3 classification_demo.py -m googlenet-v3.xml -i image.jpg -d GPU


OR


python3 ~/Downloads/open_model_zoo/demos/classification_demo/python/classification_demo.py -m googlenet-v3.xml -i image.jpg -d GPU


You can have a look at the Line 26 and 27 of classification_demo.py script. The line 26 defines the path of the monitors.py script while the line 27 defines the path of the model_zoo folder.



Regards,

Peh


Reply