Skip to content
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

YOLOv8 model transformation for a custom dataset #85

Closed
pcycccccc opened this issue Mar 27, 2024 · 3 comments
Closed

YOLOv8 model transformation for a custom dataset #85

pcycccccc opened this issue Mar 27, 2024 · 3 comments

Comments

@pcycccccc
Copy link

pcycccccc commented Mar 27, 2024

Hello, I am trying to convert my trained YOLOv8 model into a hef file. I am reading the related hailo model zoo file to figure out the documents and processes that need to be prepared.
As far as I know,
(1)Prepare an onnx model trained on my own dataset
(2)networks/yolov8.yaml(need to be modified according to the actual situation, please refer to)
(3)-calib-path path to the image dataset (does this copy the images to a folder ahead of time?)
I can get the hef model by executing the command, but I learned that to optimize and compile the model, I also need to generate the TFRecord file. Is this necessary? I have a few questions:
(1)Is TFRecord related to the third step, calib-path? How to relate?
(2)What types of files do I need to prepare in advance, an image set and a tag set? Should the tags be in xml or yolo's txt format
(3)Which py file should be run to create the TFRecord file? Do need to change any other parameters?

@tmyapple
Copy link

Hi @pcycccccc

  • For compilation of the model you don't need a TFRecord file. The TFRecord used are a serialization of open datasets, which you can reproduce using create scripts (see docs/DATA.rst for more information). It is useful for testing on benchmark datasets (i.e. coco for detection ..)
  • Calibration should be performed on your own dataset - you should create a directory with sample of your images, and use --calib-path to point there.
    hailomz compile --ckpt <path-to-your-onnx> --calib-path </path/to/calibration/imgs/dir/> --yaml <yaml_file_path>
    Regarding the YAML - preferably use a YAML corresponds to the yolov8 variant you chose, for minimal amount of changes.
    In case you have changed them model structure, then the start node and endnodes of the model might be changed... and can be modified through the YAML:
    nodes: [null , ["1st-end-node-name", "2nd-end-node-name" ... , "nth-end-node-name"]]
    If you just retrained a model on your own dataset, the start/end nodes expected to stay the same and using the correspond variant YAML will work

@pcycccccc
Copy link
Author

@tmyapple Thank you for your answer, I roughly understand, but I would like to ask: Does calib-path need to prepare an annotation file for calibration? Just provide the image set?

@pcycccccc
Copy link
Author

pcycccccc commented Mar 28, 2024

@tmyapple I got a weird error when I ran compile. I ran:

hailomz compile --ckpt /home/robot/chy/hailo_model_zoo/Liyi_Groov/Model/Groove_v8s.onnx --calib-path /home/robot/chy/hailo_model_zoo/Liyi_Groov/train --yaml /home/robot/chy/hailo_model_zoo/Liyi_Groov/Model/yolov8s_groove.yaml

My yolov8s groove.yaml file is:
image

The error content is related to Tensorflow. The version of hailo_dataflow I installed is 3.24.0, and the version of medel_zoo installed is the latest version, which is downloaded from github.

TensorFlow Addons (TFA) has ended development and introduction of new features.
TFA has entered a minimal maintenance and release mode until a planned end of life in May 2024.
Please modify downstream libraries to take dependencies from other repositories in our TensorFlow community (e.g. Keras, Keras-CV, and Keras-NLP).

For more information see: tensorflow/addons#2807

warnings.warn(
/home/robot/anaconda3/envs/HailoDF/lib/python3.8/site-packages/tensorflow_addons/utils/ensure_tf_install.py:53: UserWarning: Tensorflow Addons supports using Python ops for all Tensorflow versions above or equal to 2.11.0 and strictly below 2.14.0 (nightly versions are not supported).
The versions of TensorFlow you are currently using is 2.9.2 and is not supported.
Some things might work, some things might not.
If you were to encounter a bug, do not file an issue.
If you want to make sure you're using a tested and supported configuration, either change the TensorFlow version or the TensorFlow Addons's version.
You can find the compatibility matrix in TensorFlow Addon's readme:
https://github.com/tensorflow/addons
warnings.warn(
Start run for network Groove_v8s ...
Initializing the hailo8 runner...
[info] Translation completed on ONNX model Groove_v8s
[info] Initialized runner for Groove_v8s
[info] Loading model script to Groove_v8s from /home/robot/chy/hailo_model_zoo/hailo_model_zoo/cfg/alls/generic/yolov8s.alls
ValueError: 'yolov8' is not a valid NMSMetaArchitectures

Please ignore that I made a mistake in the info section, but I don't think it was the cause of the error in my program.
Can you help me solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants