guichristmann / edge-tpu-tiny-yolo

Run Tiny YOLO-v3 on Google's Edge TPU USB Accelerator.
MIT License
102 stars 31 forks source link

Full YoloV3 model #6

Open sathibault opened 4 years ago

sathibault commented 4 years ago

I'm wondering if you have tried building the full model (not tiny) for the Edge TPU?

raryanpur commented 4 years ago

@guichristmann would also be interested to know whether you've tried this.

ownbee commented 4 years ago

Took me some time to figure it out but now I have built the full model using the instructions with some tweaks. In the keras-yolo3 repo linked in the README, I changed activation=leaky to activation=relu in the non-tiny config file. Then created the keras-model.h5 with the convert.py script (no modification in this script) and used the keras_to_tflite_quant.py (no modification in this script either) to create the .tflite file.

With the latest tensorflow (2.3.0) and keras from pip, edgetpu_compiler failed to compile all operations so I downgraded tensorflow to 2.1.0 and keras to 2.3.1 (both were needed) and voilà:

edgetpu_compiler -s yolov3.tflite 
Edge TPU Compiler version 14.1.317412892

Model compiled successfully in 5155 ms.

Input model: yolov3.tflite
Input size: 60.00MiB
Output model: yolov3_edgetpu.tflite
Output size: 60.16MiB
On-chip memory used for caching model parameters: 6.81MiB
On-chip memory remaining for caching model parameters: 9.25KiB
Off-chip memory used for streaming uncached model parameters: 52.54MiB
Number of Edge TPU subgraphs: 1
Total number of operations: 113
Operation log: yolov3_edgetpu.log

Operator                       Count      Status

RESIZE_NEAREST_NEIGHBOR        2          Mapped to Edge TPU
CONCATENATION                  2          Mapped to Edge TPU
PAD                            5          Mapped to Edge TPU
ADD                            23         Mapped to Edge TPU
CONV_2D                        75         Mapped to Edge TPU
QUANTIZE                       6          Mapped to Edge TPU

I used the tensorflow docker image tensorflow/tensorflow:2.1.0-gpu-py3 (with nvidia-docker-runtime and installed keras in it).

Does it work on the tpu? Does it have good performance? I don't know, I have not yet run any inference with it but I will as soon as I have time...

raryanpur commented 4 years ago

@idittansikte awesome! Very interested in your results with respect to whether it runs on the tpu and the performance.

ownbee commented 4 years ago

@raryanpur I've tried it now and it loads on the edge with no errors, but I don't get any detections if i dont lower the threshold to 0. Then I get some crap out but nothing that can be used for anything. I was thinking if I need to retrain the weigths for relu.

The good news is I guess that it seem to load the model.

anuragkarwa001 commented 2 years ago

@raryanpur I've tried it now and it loads on the edge with no errors, but I don't get any detections if i dont lower the threshold to 0. Then I get some crap out but nothing that can be used for anything. I was thinking if I need to retrain the weigths for relu.

The good news is I guess that it seem to load the model.

Any progress on this, I am facing the same problem. Model is not giving me any detections after inference on edge tpu