1

My Model is the Yolov4 Darknet model. I used the "-map" function to compute the metrics there, -map function belongs to the darknet.

However, when converting my model to tensorflow lite, I want to recompute these metrics on the tensorflow model in between. So actually my question is how can I find values like f1 score, mean average precision..etc on my yolov4-416 tensorflow model?

elif
  • 11
  • 3

1 Answers1

0

It is hard to answer as repo which you use is unknown for us. You can calculate it with formula of mAP, but which iou threshold will be used depends on you. Often it is 0.5, so mAP@0.5 will be calculated as:

  1. Set IoU threshold to 0.5
  2. Calculate AP as: TP/(TP+FP) where TP stand for True Positives and FP stands for False Positives per each class.
  3. Then calculate mAP as average of AP. If you are using hunglc007, then try this:
  4. Convert to framework which you are will use(in your project, it is tflite):

python save_model.py --weights ./path/to/your/weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4 --framework tflite python convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416.tflite --quantize_mode( you can use eiter float16 or int8)

  1. Evaluate your TFLite model: python evaluate.py --weights ./checkpoints/yolov4-416.tflite --framework tflite --input_size 416 --model yolov4 --annotations /path/to/your/annotations.txt
  2. Calculate mAP: cd mAP/extra python remove_space.py cd .. python main.py --output results_yolov4_tflite
  3. Then watch in mAP/results_yolov4_tflite/results.txt for your mAP
TheGamerCoder
  • 91
  • 1
  • 11
  • Thanks for your answer. My Model is the **Yolov4 Darknet** model. I used the **"-map"** function to compute the metrics there, -map function belongs to the darknet. However, when converting my model to tensorflow lite, I want to recompute these metrics on the tensorflow model in between. So actually my question is how can I find values like f1 score, mean average precision..etc on my **yolov4-416 tensorflow** model? – elif Jul 13 '21 at 07:11
  • Thanks for reply. Can you show which repo you currently using, please? Hunglc007(theAiGuysCode cloned that repo) or smth else. If hunglc007 or theaiguyscode, there is mAP folder, under which main.py is. As I understand you should play with mAP/main.py, as there is no path to model. Try o implement.) – TheGamerCoder Jul 13 '21 at 10:18
  • My custom object detection model is Darknet model. I converted to Tflite model from hunglc007 repo. Firstly, I obtained yolov4-416 model. It includes saved_model.pb model. I tried mAP/main.py script as you mentioned. But my model is custom model. So, I can not convert it to my model. Do you have any idea for this point?.And thank you for your detail explanation. – elif Jul 13 '21 at 21:03
  • I am getting these errors. In additionI tried to reach you. However, I couldn't reach it. I try so hard but I can't. – elif Jul 17 '21 at 14:13
  • When I '**python main.py --output results_yolov4_tflite**'. as you mentioned I am getting error : '**Traceback (most recent call last): File "main.py", line 643, in mAP = sum_AP / n_classes ZeroDivisionError: float division by zero**' I can not solve it. I changed file paths all of the related files. Could you help me, please? – elif Jul 17 '21 at 19:17
  • It seems that n_classes is 0 for ur case. Try to check your configurations with ur dataset .yaml – TheGamerCoder Sep 11 '22 at 11:11