There seems to be a few issues for running some of the functions on colab.
Converting to TFLite works for detect.py.
But, for videos, the classifications and detections are way off. For example, in people videos, no people are being detected, instead, elephants and zebras are detected with high confidence. In car videos, no cars are detected.
Restricting the classification to allowed classes (people and cars) doesn't work either, as nothing gets detected anymore.
Ran into errors of "cannot connect to server X"
To bypass error, commented the following in detect_video.py
"#cv2.namedWindow()
%cd /content/yolov4-custom-functions
!ls
# convert the model from yolov4 to tensorflow then TFLite
# Save tf model for tflite converting
!python3 /content/yolov4-custom-functions/save_model.py --weights /content/drive/MyDrive/object_counting_yolov4/pre-trained_weights/yolov4.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4 --framework tflite
# yolov4
!python3 /content/yolov4-custom-functions/convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416.tflite
# yolov4 quantize float16
#!python3 /content/yolov4-custom-functions/convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416-fp16.tflite --quantize_mode float16
# yolov4 quantize int8 - for whatever reason the /coco_dataset/coco/val207.txt is missing. RPi is a float based anyways.
#!python3 /content/yolov4-custom-functions/convert_tflite.py --weights ./checkpoints/yolov4-416 --output ./checkpoints/yolov4-416-int8.tflite --quantize_mode int8 --dataset ./coco_dataset/coco/val207.txt
# to change the count from total number of objects to number of objects per class:
# change
#if FLAGS.count:
# by_class = True
# Run tflite model
!python3 detect.py --weights ./checkpoints/yolov4-416.tflite --size 416 --model yolov4 --images ./data/images/dog.jpg --framework tflite --count
Number of bicycles: 1
Number of dogs: 1
Number of trucks: 1
Testing on another image
# Run tflite model
!python3 detect.py --weights ./checkpoints/yolov4-416.tflite --size 416 --model yolov4 --images ./data/images/kite.jpg --framework tflite --count
Number of persons: 7
Number of kites: 6
# Run yolov4 on video
# similarly, change total count type from total number to total count per class
# by changing
#if FLAGS.count:
# by_class = True
!python3 detect_video.py --weights ./checkpoints/yolov4-416 --model yolov4 --video ./data/video/cars.mp4 --output ./detections/results.avi --dont_show --framework tf --info
# more details for each detection, inlcuding confidence, BBox coordinates: --info instead of --count
# Run yolov4 on webcam
# !python3 detect_video.py --weights ./checkpoints/yolov4-416 --size 416 --model yolov4 --video 0 --output ./detections/results.avi
Hey,
Thank you for another amazing tutorial/repo.
There seems to be a few issues for running some of the functions on colab.
Converting to TFLite works for detect.py.
But, for videos, the classifications and detections are way off. For example, in people videos, no people are being detected, instead, elephants and zebras are detected with high confidence. In car videos, no cars are detected. Restricting the classification to allowed classes (people and cars) doesn't work either, as nothing gets detected anymore.
Ran into errors of "cannot connect to server X" To bypass error, commented the following in detect_video.py "#cv2.namedWindow()
cv2.destroyAllWindows()
reproduce issue: Colab
Convert darknet weights to tensorflow
The weights folder is on my google drive.
Number of bicycles: 1 Number of dogs: 1 Number of trucks: 1
Testing on another image
Number of persons: 7 Number of kites: 6