Closed JimBratsos closed 3 years ago
Did you install yolov4?
python -m pip install yolov4
And, YOLOv4-tiny cannot be run on coral because its activation is leaky-relu. Ref: https://coral.ai/docs/edgetpu/models-intro/#supported-operations
So, If you want, you should set the activation function to relu.
from yolov4.tf import YOLOv4
yolo = YOLOv4(tiny=True)
yolo.classes = "coco.names"
yolo.make_model(activation1="relu")
yolo.load_weights("yolov4-tiny-relu.weigths", weights_type="yolo")
convertion Ref: https://github.com/hhk7734/tensorflow-yolov4/blob/master/test/make_edgetpu_tflite.ipynb
Thanks a lot for the quick reply my friend and for your time
I have indeed installed yolov4 as you said at your first reply. I also tried following your guide for tflite conversion, but this is where the error popped up. I will try it once more now and will report back in a minute. Can this procedure be done for yolov4 too or just its tiny version?
Thanks
I failed on yolov4. I think yolov4 model is too big.
So I tried running the script again but I renamed it from yolov4 to another name and now it miraculously worked :P ! I don't know if the name of the file was the problem or not. Now the only thing that remains is to put the correct path to the whole coco 2017 dataset and to provide a txt file. Do I have to make a txt file for every single image in the coco dataset? I have tried yolov3 but I failed on quantization. Same for yolov4 of course. I hope this method works it is my last hope
coco.names, train2017.txt, val2017.txt are in https://github.com/hhk7734/tensorflow-yolov4/tree/master/test/dataset
Thanks a lot for the help. I have some issues extracting the dataset, but once I finish it I will report back asap
Hello, I tried running the script and provided the tiny relu model given, plus the information from the dataset folder. I also used the coco 2017 train dataset as of course specified in the code. I executed it, and it hanged for 20 minutes, ultimately giving me this error: RuntimeError: Unsupported output type INT8 for output tensor 'Identity' of type FLOAT32. This is how I edited the code to match my system, other than that I changed nothing. Maybe there is something wrong with the paths of mine, or the way I entered them at the code.
from yolov4.tf import YOLOv4
yolo = YOLOv4(tiny=True, tpu=True)
yolo.classes = "./coco/dataset/coco.names" #path to coco.names
yolo.make_model(activation1="relu")
yolo.load_weights("yolov4-tiny-relu.weights", weights_type="yolo") #weights file is in the same directory
dataset = yolo.load_dataset(
"./coco/dataset/train2017.txt", #path to the train text
training=False,
image_path_prefix=r"C:\Users\Jim\Desktop\int8post\coco\train2017" #contains all the 2017 train images
)
yolo.save_as_tflite(
"yolov4-tiny-relu.tflite",
quantization="full_int8",
data_set=dataset,
num_calibration_steps=500
)
Install TF 2.2.0 and try again. I failed to convert when using 2.3.0.
Thank you very very much, it all works successfully. I will test the model the next days, I really appreciate your help you can't find that everywhere
Good evening, and thank you for your great work! I have an error ( it's the title of my issue ) while executing the script to run the conversion of YoloV4 to TFlite. Any ideas what I have been doing wrong? Sorry for the trouble. I am using Windows, and I have Python 3.7.0, using an anaconda environment with tensorflow-gpu/tensorflow version 2.3.0. Any help would be much appreciated.
Also quick question since I am a beginner; I have been trying to convert YOLOv3 and YOLOv4 weights to int8 quantized Tflite to run them to Coral for quite some time without success. Could I do it, at least for YOLOv4-tiny using this script? Again, I am a beginner and any help would be much appreciated!