thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

How to run yolov2-lite tflite in coral edge TPU USB accelerator? #1087

Open AbhishekNalamothu opened 4 years ago

AbhishekNalamothu commented 4 years ago

@thtrieu, I would like to make sure whether the following steps I executed to get the tflite of yolov2-lite model are correct or not? Step1 Saving graph and weights to protobuf file flow --model cfg/yolov2-tiny.cfg --load bin/yolov2-tiny.weights --savepb. This command created build_graph folder with yolov2-tiny.pb and yolov2-tiny.meta. Step2 Converting pb to tflite I executed the below piece of code to get the yolov2-tiny.tflite

import tensorflow as tf  
localpb = 'yolov2-tiny.pb' 
tflite_file = 'yolov2-tiny.tflite'  
print("{} -> {}".format(localpb, tflite_file)) 
converter = tf.lite.TFLiteConverter.from_frozen_graph(
localpb,   
input_arrays= ['input'],   
output_arrays= ['output']    
)  
tflite_model = converter.convert()  
open(tflite_file,'wb').write(tflite_model)  
interpreter = tf.lite.Interpreter(model_content=tflite_model)  
interpreter.allocate_tensors()

If the above steps I followed to get this tflite are correct, then please suggest me the command to run this tflite file in coral edge TPU USB accelerator.

Thank you so much :)