fix to run on TF2.4
albertnew2012 opened this issue · 6 comments
I don't understand why the code wouldn't run on TF2.4, but I found the reason causing the failure. Taking detection_demo.py
as an example, detect_video
, detect_realtime
and detect_screen
all fail, but one just needs to make a tiny change in utils.py
:
if YOLO_FRAMEWORK == "tf":
pred_bbox = yolo.predict(image_data)
by changing yolo.predict
->yolo
, then it works like a charm again.
I looked up online, it seems there is no difference between model.predict()
and model()
, but anyhow it fails the code in TF2.4.
Happy learning,
Cheers
@ZhengzhiLiu are you able to reproduce the same results in terms of speed on your machine? If yes, can you tell me how fast the detect_video is running and what GPU you are using? I am unable to reproduce the quoted results in terms of fps using pretrained yolov4/yolov3 model files
@yugkhanna I was able to reproduce the reported about 20 FPS in the code README.md on both TF2.3 and TF2.4. In order to run the code on TF2.4, you may need to make the changes as I mentioned above. On TF2.4 detect_video runs at 20 FPS on my RTX3080 (only support TF2.4 and above for GPU version)
.
YOLO tiny is able to run at 55 FPS, but the result is bad, bbox is too small and does not cover the entire object, and sometimes a single object has multiple bboxes, it seems nms failed.
@ZhengzhiLiu I also noticed like @yugkhanna that with this fix at detect_video the fps are lower than before.
I have tested with detection_demo and the test.mp4 file.
In comparison (Python 3.7, TF 2.3, GPU: 980ti):
yolo.predict(image_data) i get ~16fps
yolo(image_data) i get ~8fps
Do you have any idea what could be the reason for this?
I also noticed at TF >= 2.4 that when printing pred_bbox in detect_video with yolo.predict(image_data), the bounding boxes contain correct values in the first frame and then consist only of nan.
I also noticed at TF >= 2.4 that when printing pred_bbox in detect_video with yolo.predict(image_data), the bounding boxes contain correct values in the first frame and then consist only of nan.
@Crytap I'm currently struggling with exactly this problem. Do you have any advice which tf version to use?
@JuliusJacobitz With TF 2.3 everything works without any problems.
@ZhengzhiLiu Hello. What other changes have you made to increase the frame rate to 21?