-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
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
How to really use exported Tensorflow Lite model? #5030
Comments
👋 Hello @pyro000, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com. RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 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 YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
I have this colab notebook to show what I've done by now, if anybody can help me or link me anything useful I would be very grateful. |
@pyro000 exported YOLOv5 models do not contain Line 78 in cce7e78
@zldrobit this issue seems to come up often, users are understandably confused when detection names are not shown with TFLite detect.py inference. Is there any way to embed names arrays in a TFLite model? EDIT: @zldrobit I know previously you defaulted to COCO names, but users will arrive here with custom-trained models also. |
The problem is that with the example provided by the tutorial and the labels that I defined manually in Or am I missing something? Any help is really appreciated. |
@pyro000 your link goes to a 3rd party that I don't recognize. The official YOLOv5 colab is Running inference with TFLite models is very easy:
|
That's the code I did to make the predictions of the model in Python, loading the model with
Yes I'm aware that with detect.py works perfectly but how do I make my own code only for tflite model? The methods in the TF docs doesn't work. |
@pyro000 oh I see. I don't have experience with the TF OD API, I'm sorry. You should try reposting this issue on the https://github.com/tensorflow/models repository to see if you can get help there. |
Yes I just realised this is TF issue, I'll close this. |
@glenn-jocher We may embed metadata in TFLite, e.g. https://www.tensorflow.org/lite/convert/metadata_writer_tutorial#object_detectors for object detection model. But this requires the TFLite model integrate with the NMS op. Considering the support of NMS in TFLite/TF.js, not all use cases could be covered by any type of the NMS ops. So I suggest we keep the NMS op in TFLite as an experimental branch for now. |
@pyro000 After exported the TFLite model, you could use my fork repo to run the model on Android devices. |
@zldrobit got it, thanks! Will leave this alone for now then. |
An example of how to use a yolov5.tflite model inside a TFLite application (besides just using |
@EdjeElectronics We plan to release an example for using yolov5.tflite in a TFLite app soon. In the meantime, I recommend referring to the TFLite image classification example on the TensorFlow website as a starting point for TFLite deployment. |
❔Question
Following this tutorial: https://towardsdatascience.com/using-tensorflow-lite-for-object-detection-2a0283f94aed
I get with
interpreter.get_tensor(output_details[1]['index'])[0]
Index Error, because this model doesn't have labels or classes inside it.Trying to understand
detect.py
andgeneral.py
seems really dificult for me.Is there any introduction of how to display results with this model and include the labels from yolov5 with Python? or what source do I have to use to make this?
Additional context
Using
detect.py
works as intended but instead of naming the objects, it appears as "class0", "class20"...The text was updated successfully, but these errors were encountered: