google-coral / pycoral

Python API for ML inferencing and transfer-learning on Coral devices
https://coral.ai
Apache License 2.0
347 stars 144 forks source link

How to run yolov5(pytroch) in google-TPU Dev Board #54

Closed luckywangchenxi closed 2 years ago

luckywangchenxi commented 2 years ago

Description

Hi, I am a student and I want to deploy yolov5 to google-TPU Dev Board. I would like to ask how to run https://github.com/ultralytics/yolov5 on google-TPU Dev Board (https://coral.ai/products/dev-board) . From what I have checked so far

  1. Need to convert pytorch to TensorFlow via onnx.
  2. Convert tflite model to tflite-tpu model.
  3. Then deploy to google-TPU development board. If you can describe the exact process, it would be greatly appreciated, thanks!
Click to expand! ### Issue Type Build/Install ### Operating System _No response_ ### Coral Device Dev Board ### Other Devices _No response_ ### Programming Language Python 3.7 ### Relevant Log Output _No response_
hjonnala commented 2 years ago

Hi @luckywangchenxi do you have the yolov5 tflite model? if so, please convert it to edgetpu model using this tutorial.

luckywangchenxi commented 2 years ago

ok ,thank you.I will try it.

luckywangchenxi commented 2 years ago

Hi ,Follow the tutorial you sent ,I have converted the yolov5 tflite model to edgetpu model successfully. 图片 Then ,How do I deploy this edgetpu model to the Edge TPU ? Thanks! 图片

hjonnala commented 2 years ago

Please try to deploy the model either git clone <repo path> if you have it on github or using mdt push <path to of edgeptu model>.

Unfortunately, We don't have any example script to run the inference with pytorch for yolov5 model. Here is example inference script for yolov4 model.

Namburger commented 2 years ago

@luckywangchenxi I just made a pull request to that repo that contains the change to run edgetpu models: https://github.com/ultralytics/yolov5/pull/5372/commits/63b41529873a03647254ca216c6d2a6890f3416e

Here are the model files: model.zip I'm using the nano model, unfortunately I'm only getting about 8fps on usb3 and about 4fps on usb2

python3 detect.py --source 0 --weights yolov5n-int8_edgetpu.tflite
luckywangchenxi commented 2 years ago

@Namburger ok ,thank you.I will try it.

luckywangchenxi commented 2 years ago

@hjonnala ok ,thank you.I will try it.

hjonnala commented 2 years ago

Feel free to reopen if you have questions.

google-coral-bot[bot] commented 2 years ago

Are you satisfied with the resolution of your issue? Yes No

atbdeveloper commented 4 months ago

Anyone knows about the process for run Yolo V9 inside google coral board?

CarlosNacher commented 4 months ago

Description

Hi, I am a student and I want to deploy yolov5 to google-TPU Dev Board. I would like to ask how to run https://github.com/ultralytics/yolov5 on google-TPU Dev Board (https://coral.ai/products/dev-board) . From what I have checked so far

  1. Need to convert pytorch to TensorFlow via onnx.
  2. Convert tflite model to tflite-tpu model.
  3. Then deploy to google-TPU development board. If you can describe the exact process, it would be greatly appreciated, thanks!

Click to expand!

Hey @luckywangchenxi ! I am trying to convrt pytorch to tensorflow but it is proving frustrating, could you please help me?

I have converted from pytorch to onnx, which is simple with torch.onnx.export() method. But the step to convert onnx to tensorflow, I don't find any library that achieves it. I found https://github.com/onnx/onnx-tensorflow but it has not been mantained for 2 years and when I try it, a lot of dependency errors raise. I would really appreciate your help, thank you in advance!

luckywangchenxi commented 4 months ago

Description

Hi, I am a student and I want to deploy yolov5 to google-TPU Dev Board. I would like to ask how to run https://github.com/ultralytics/yolov5 on google-TPU Dev Board (https://coral.ai/products/dev-board) . From what I have checked so far

  1. Need to convert pytorch to TensorFlow via onnx.
  2. Convert tflite model to tflite-tpu model.
  3. Then deploy to google-TPU development board. If you can describe the exact process, it would be greatly appreciated, thanks!

Click to expand!

Hey @luckywangchenxi ! I am trying to convrt pytorch to tensorflow but it is proving frustrating, could you please help me?

I have converted from pytorch to onnx, which is simple with torch.onnx.export() method. But the step to convert onnx to tensorflow, I don't find any library that achieves it. I found https://github.com/onnx/onnx-tensorflow but it has not been mantained for 2 years and when I try it, a lot of dependency errors raise. I would really appreciate your help, thank you in advance!

Sorry, I am no longer working on this project. I wish you all the best.

CarlosNacher commented 4 months ago

@luckywangchenxi don't worry, thank you for your quick response. As help for others with the same problem, I have been able to convert onnx to tensorflow with the following repo: https://github.com/PINTO0309/onnx2tf