xslittlegrass / CarND-Vehicle-Detection

Vehicle detection using YOLO in Keras runs at 21FPS
389 stars 175 forks source link

Can't convert float nan to integer #13

Closed KaushikNathMIT closed 6 years ago

KaushikNathMIT commented 7 years ago

In draw box function in utils.py, error starting from line 105. "Can't convert float nan to integer "

nlinc1905 commented 7 years ago

The error appears because the height (h) and width (w) variables of the bounding box are infinitesimally small. This applies to the yolo_net_out_to_car_boxes function in the utils.py file. The code below clears up the error, because (a*b)^x = a^x + b^x, and the nan will be replaced by 0.

if np.isnan(cords[grid, b, 2] ** sqrt):
    bx.w = np.exp(cords[grid, b, 2] + sqrt)
else:
    bx.w = cords[grid, b, 2] ** sqrt
if np.isnan(cords[grid, b, 3] ** sqrt):
    bx.h = np.exp(cords[grid, b, 3] + sqrt)
else:
    bx.h = cords[grid, b, 3] ** sqrt
943460395 commented 6 years ago

Can I ask a funny question? where shoula i insert these codes??I have try many times,but could not walk