experiencor / keras-yolo3

Training and Detecting Objects with YOLO3
MIT License
1.61k stars 861 forks source link

Detection, Float32 overflow to inf #339

Closed theATM closed 1 year ago

theATM commented 1 year ago

Hi I am following the detection instruction on the readme. I have downloaded the pretrained weights of yolo3 (from link in readme) and I am trying to test detection on random image form internet. I am using python 3.5.6 with all libs installed according to the requirements.txt (linux with cuda 10.0 installed)

I am using this command to run: python yolo3_one_file_to_detect_them_all.py -w yolov3.weights -i 00001.jpg But the code encountered problem in the decode_netout() function while calculating x, y, w, h. In the operation -> np.exp(h) code returns inf (ex: np.exp(405)). Because it reaches max float32 value. Have any one else encountered this problem? Am I doing something wrong?

Eventual error comes when it tries to change type to int: RuntimeWarning: overflow encountered in exp w = anchors[2 b + 0] np.exp(w) / net_w # unit: image width Traceback (most recent call last) (...): line 453 correct_yolo_boxes(boxes, image_h, image_w, net_h, net_w): line 365, in correct_yolo_boxes: boxes[i].ymin = int((boxes[i].ymin - y_offset) / y_scale * image_h) OverflowError: cannot convert float infinity to integer

theATM commented 1 year ago

Ech, of course this code is written in tensorflow 1 and thus it is incompatible with modern GPUs (even when cuda10 was installed). Lucky, I founded on internet that nvidia has a cuda 11 compatible, tensorflow 1.15 fork which is available in docker or as in this tutorial can be installed in cuda env. For me it solved the problem.