-
-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
Convert to Tensorflow.js model #2127
Comments
👋 Hello @pravastacaraka, 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com. RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ 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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@pravastacaraka yes, you can convert to TF js by exporting to TF first and then onward to js. See #1127 for TF export. |
@glenn-jocher I have an issue with the Colab, when I try to export use There is an error
Is there something wrong? |
@pravastacaraka Keras and TF export should be working, but I remember seeing a similar error message on the PR. Is this error reproducible with the default models? Also I'm not sure if export is verified with TF 2.4.1, only TF 2.4.0 as far as I've seen. |
@glenn-jocher I haven't tried to convert the default model from YOLOv5.
I tried this on Colab, should I change the Tensorflow version to 2.4.0 first? Because I have tried it on my laptop with installed TF 2.4.0 and PyTorch 1.7.1 the results are the same as the error I showed before. Then I tried to change to TF 2.3.0, and PyTorch 1.6.0 resulted in a different error. Here it is the error:
|
@pravastacaraka yes your new error is expected. torch requirements are >=1.7.0. In your results then it seems that 2.4.1 and 2.4.0 behave identically for our intents and purposes. You may want to verify export with a default model before trying a custom model to remove your model as a source of error. |
@glenn-jocher Ahh... I have tried it for the YOLOv5s default model, and it works. What's wrong with my training custom model? |
@pravastacaraka it's likely just out of date. I would git clone a new copy fo the repo and retrain your model, then it will export correctly. |
Can I use the previous model as my checkpoint? |
Do you have a nms code written in tfjs to share? I was able to convert model to tfjs correctly, but I am struggling to parse boxes and scores after the prediction. Thanks! |
@batrlatom can you use the TF JS NMS function here? |
@glenn-jocher where can I put the code? |
@pravastacaraka I think if you are building a TF JS version of YOLOv5 you should pipeline a nonMaxSuppression() layer immediately after the Detect() layer, but I'm a little light on details as I actually have not gone down this path myself. |
@pravastacaraka @batrlatom was anybody able to implement the non-max-suppression and can share the javascript code? I followed the implementation from https://github.com/ModelDepot/tfjs-yolo-tiny , but I am getting wrong output. |
@anas-899 yes, i still haven't found a way to implement the nms either |
@anas-899 that repo uses yolo v3, built on darknet not torch. |
How were you able to get the prediction!!!!!!! i'm getting |
@batrlatom Have you found the solution? @dewball345 As I explained here tensorflow/tfjs#4637 (comment) |
@batrlatom @anas-899 @LundinMachine @dewball345 I have updated |
@zldrobit I also created a repo with nms, but in addition it contains some preprocessing/postprocessing utilities as well as other stuff like drawing to canvas. https://github.com/dewball345/ear.js |
@dewball345 That's cool. I looked into the repo and found that you used |
@zldrobit Oh my, i didn't realize that. I'm using a relatively high-end pc, so the 12 fps is definitely not that accurate. Thanks for bringing this up, I've changed my readme so as to not mislead others |
Originally i used tf.image.nonMaxSuppression, but i got a warning in my console. |
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐! |
how to convert model .pt to tflite |
@thaingoc2604 see TFLite, ONNX, CoreML, TensorRT Export 🚀 tutorial for TFLite export instructions: YOLOv5 Tutorials
|
Hi, @glenn-jocher 👋! I just wanted to let you know, that I created a yolov5js npm package that allows for almost effortless deployment of YOLOv5 models converted to tensorflow.js format on websites. I actually used the newly created package, to add YOLOv5 support in makesense.ai. Here is a pre-release instance and a short video showcasing new feature. 2022-09-30-08-54-57-small.mp4 |
Hi @SkalskiP, that's fantastic to hear! It's great to see the YOLOv5 community thriving and building innovative tools. Congratulations on creating the |
❔Question
Hello,, is it possible to convert the YOLOv5 PyTorch model to the Tensorflow.js model?
The text was updated successfully, but these errors were encountered: