Comments (6)
👋 Hello @aidansmyth95, 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.
Install
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
Environments
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If 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.
from ultralytics.
ERROR: input_onnx_file_path: yolov8n.onnx
ERROR: onnx_op_name: /model.10/Resize
ERROR: Read this and deal with it. https://github.com/PINTO0309/onnx2tf#parameter-replacement
ERROR: Alternatively, if the input OP has a dynamic dimension, use the -b or -ois option to rewrite it to a static shape and try again.
ERROR: If the input OP of ONNX before conversion is NHWC or an irregular channel arrangement other than NCHW, use the -kt or -kat option.
ERROR: Also, for models that include NonMaxSuppression in the post-processing, try the -onwdt option.
from ultralytics.
@aidansmyth95 hi there,
Thank you for reaching out and for providing detailed information about the issue you're encountering. Let's work through this together to get your TensorFlow and TFLite exports functioning correctly.
Steps to Resolve the Issue
-
Ensure Latest Versions:
First, please make sure you are using the latest versions oftorch
andultralytics
. You can upgrade them using the following commands:pip install --upgrade torch ultralytics
-
Install TensorFlow and TFLite Dependencies:
Ensure you have the necessary TensorFlow and TFLite dependencies installed. You can install them using:pip install tensorflow tensorflow-addons
-
Minimum Reproducible Example:
To help us better understand and reproduce the issue, could you please provide a minimum reproducible code example? This will allow us to investigate the problem more effectively. You can refer to our guide on creating a minimum reproducible example here: Minimum Reproducible Example. -
Exporting to TFLite:
Here is a sample code snippet to export a YOLOv8 model to TFLite format:from ultralytics import YOLO # Load the YOLOv8 model model = YOLO("yolov8n.pt") # Export the model to TFLite format model.export(format="tflite") # creates 'yolov8n_float32.tflite'
-
Handling ONNX Errors:
The errors you are seeing suggest issues with the ONNX model's dimensions or operations. You can try the following options as suggested:- Use the
-b
or-ois
option to rewrite dynamic dimensions to static shapes. - Use the
-kt
or-kat
option if the input OP of ONNX has an irregular channel arrangement. - For models including NonMaxSuppression in post-processing, try the
-onwdt
option.
For more detailed information, you can refer to the onnx2tf documentation.
- Use the
Additional Resources
For further details on exporting models to TFLite, you can visit our documentation here: YOLOv8 to TFLite Export Guide.
If you continue to experience issues, please provide the minimum reproducible example, and we will be happy to assist you further.
from ultralytics.
Hi, which packages and version numbers are tested and worked? Is it a requirements.txt or .toml file that works for TF export?
I have tried nearly every combination of TensorFlow and onnx2tf and am still struggling to get it to export. It seems that version really matters here, so I am curious as to what works for you. I am using Python 10.
pip install ultralytics
pip install tensorflow==2.16.0 tf_keras==2.16.0 onnxtf==1.22.0 torch==2.0.1 torchvision==0.15.2 ultralytics==8.0.186 tensorflow==2.13.0 opencv-python==4.8.0.76 h5py==3.10.0 flatbuffers==24.3.25
pip install onnx
pip install tensorflow==2.16.1 tf_keras==2.16.0 onnx2tf==1.22.0 torch==2.0.1 torchvision==0.15.2 ultralytics==8.0.186 opencv-python==4.8.0.76 h5py==3.10.0 flatbuffers==24.3.25 onnx
pip install sng4onnx onnxslim==0.1.28 onnx_graphsurgeon tflite_support onnxruntime
Hoping it is specified somewhere that has been tested recently and works for yolov8n.pt, no package version guessing or trial and error required.
from ultralytics.
Hi @aidansmyth95,
Thank you for reaching out and providing detailed information about the packages and versions you've tried. Let's work together to resolve this issue.
Steps to Resolve the Issue
-
Verify Latest Versions:
Ensure you are using the latest versions oftorch
andultralytics
. You can upgrade them using:pip install --upgrade torch ultralytics
-
Install TensorFlow and TFLite Dependencies:
The following command installs the necessary dependencies for TensorFlow and TFLite:pip install tensorflow tensorflow-addons
-
Minimum Reproducible Example:
To help us better understand and reproduce the issue, could you please provide a minimum reproducible code example? This will allow us to investigate the problem more effectively. You can refer to our guide on creating a minimum reproducible example here: Minimum Reproducible Example.
Recommended Package Versions
Based on our testing, the following package versions should work for exporting YOLOv8 models to TFLite:
pip install ultralytics==8.0.186 torch==2.0.1 torchvision==0.15.2 tensorflow==2.13.0 onnx==1.13.1 onnx2tf==1.22.0 opencv-python==4.8.0.76 h5py==3.10.0 flatbuffers==24.3.25
Exporting to TFLite
Here is a sample code snippet to export a YOLOv8 model to TFLite format:
from ultralytics import YOLO
# Load the YOLOv8 model
model = YOLO("yolov8n.pt")
# Export the model to TFLite format
model.export(format="tflite") # creates 'yolov8n_float32.tflite'
Handling ONNX Errors
The errors you are seeing suggest issues with the ONNX model's dimensions or operations. You can try the following options as suggested:
- Use the
-b
or-ois
option to rewrite dynamic dimensions to static shapes. - Use the
-kt
or-kat
option if the input OP of ONNX has an irregular channel arrangement. - For models including NonMaxSuppression in post-processing, try the
-onwdt
option.
For more detailed information, you can refer to the onnx2tf documentation.
Additional Resources
For further details on exporting models to TFLite, you can visit our documentation here: YOLOv8 to TFLite Export Guide.
If you continue to experience issues, please provide the minimum reproducible example, and we will be happy to assist you further.
from ultralytics.
@aidansmyth95 I had same problem on Windows, switched to WSL (Ubuntu) and works fine.
from ultralytics.
Related Issues (20)
- wandb shows unused labels after COCO transfer-learning HOT 5
- Issue with Training YOLOv8 on a Large Dataset with lack of memory and not good enough HOT 4
- Fail to run on videos from some specific cameras HOT 1
- ScannerError when import ultralytics HOT 2
- Continuous learning: top1_acc lower than before HOT 10
- Confidence Labels HOT 4
- img and orig_imgs HOT 1
- Getting all the mAP50-95 interval values for IoU thresholds ranging from 0.50 to 0.95. HOT 4
- YOLO-6D-Pose: Enhancing YOLO for Single-Stage Monocular Multi-Object 6D Pose Estimation HOT 2
- False Positive rate is high with YOLOv8 Pose Model on CCTV camera feeds HOT 6
- AttributeError: "OBB" object has no attribute "xyxy". See valid attributes below. HOT 7
- What are the input layer name and output layer name of yolov8? HOT 1
- yolov8 segmenation parameter questions HOT 3
- Sudden FPS drop on a MacBook Pro with M3 Max HOT 5
- exe file for yolov8 using openvino goes on loop HOT 4
- When I was training the dataset, I enabled AMP. I downloaded yolov8n.pt into the ultralytics folder and the ultralytics/ultralytics folder. During the first few training sessions, I wasn't prompted to download yolov8n.pt, but after training a few times, I was prompted that AMP needs to download yolov8n.pt and it keeps waiting for the download. My server is extremely slow at downloading from GitHub, so I want to know where exactly I should place the .pt file so that it can be automatically detected during runtime? HOT 3
- When using OBB training, I found that the number of predicted objects after post-processing did not match the final result number HOT 4
- yolov8 predict: 'DetectionModel' object has no attribute 'end2end' HOT 5
- Modify Yolov8 output size HOT 7
- Libraries misalignment in ultralytics and super_gradients required for model YOLO-NAS HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.