-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imgsz bug when using openvino #12841
Comments
👋 Hello @KeitoKohinata, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered. If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it. If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results. Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users. InstallPip install the pip install ultralytics EnvironmentsYOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit. |
Hello, Thanks for reporting this issue. It seems like the model export did not correctly translate the image size ( The error you're encountering suggests that the image size expected by the OpenVINO model is still set to the default (640x640) rather than what you used during training (320x320). To ensure the exported model uses the right model.export(format="openvino", imgsz=320) This should help align the expected input size of your model with the actual data passing through during prediction. Be sure to consistently use the same image size you trained with when exporting and running predictions. If the problem persists after trying this fix, it may indeed be a bug. I'd recommend watching the issue tracker for updates related to this problem or any patch that might address it. Good luck! |
Thank you for your reply. |
Hello, Thank you for the clarification. If you've already exported the model with Here's a quick check you can perform when loading the model for prediction: model = YOLO("best_openvino_model", task="detect")
result = model.predict(numpy_image, imgsz=320) This explicitly sets the image size when loading the model, which might help resolve any discrepancies. If the issue persists, it could be a bug, and I recommend opening an issue on the repository for further investigation. Hope this helps! 😊 |
Thank you for your reply. YOLO() does not have imgsz as an argument. Therefore, your suggested code will result in an error. Are you using another "YOLO" that is not "from ultralytics import YOLO" ? Also, even if you solved the problem by explicitly specifying the argument that way, it would be a bit tedious to specify it, since the openvino model should keep the information about the imgsz. |
@KeitoKohinata ah yes, you're right! The model = YOLO("best_openvino_model", task="detect")
result = model.predict(numpy_image, imgsz=320) |
Thank you for your reply. |
@KeitoKohinata great to hear that it worked! If you have any more questions or run into other issues, feel free to reach out. Happy coding! 😊 |
Search before asking
YOLOv8 Component
Predict
Bug
I get an error when I run the following program.
After training on a non-640 imgsz, export to the openvino model.
When predict() is run on the model, the following error is output for imgsz.
"the input tensor size is not equal to the model input tyep: got [1,3,640,640] expecting [1,3,320,320]"
I assume that this is because the imgsz information is not read from yaml when the openvino model is loaded.
Is this error caused by my program being inadequate? Or is it a bug?
(If it is a bug, I think it needs to be resolved by adding a process to YOLO._load() that reads the yaml and sets the imgsz appropriately, etc.)
Translated with DeepL.com (free version)
Environment
No response
Minimal Reproducible Example
train and export
model.train(
data="dataset.yaml",
epochs=20,
imgsz=320,
project="myproject",
)
model.export(format="openvino", imgsz=imgsz)
predict
model = YOLO("best_openvino_model", task="detect")
result = model.predict(numpy_image) # error
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: