GithubHelp home page GithubHelp logo

Comments (6)

github-actions avatar github-actions commented on July 29, 2024

👋 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):

Status

Ultralytics CI

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.

aidansmyth95 avatar aidansmyth95 commented on July 29, 2024

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.

glenn-jocher avatar glenn-jocher commented on July 29, 2024

@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

  1. Ensure Latest Versions:
    First, please make sure you are using the latest versions of torch and ultralytics. You can upgrade them using the following commands:

    pip install --upgrade torch ultralytics
  2. 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
  3. 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.

  4. 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'
  5. 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 avatar aidansmyth95 commented on July 29, 2024

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.

glenn-jocher avatar glenn-jocher commented on July 29, 2024

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

  1. Verify Latest Versions:
    Ensure you are using the latest versions of torch and ultralytics. You can upgrade them using:

    pip install --upgrade torch ultralytics
  2. Install TensorFlow and TFLite Dependencies:
    The following command installs the necessary dependencies for TensorFlow and TFLite:

    pip install tensorflow tensorflow-addons
  3. 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.

owainc avatar owainc commented on July 29, 2024

@aidansmyth95 I had same problem on Windows, switched to WSL (Ubuntu) and works fine.

from ultralytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.