abewley / sort

Simple, online, and realtime tracking of multiple objects in a video sequence.
GNU General Public License v3.0
3.82k stars 1.07k forks source link

Getting [ZeroDivisionError: float division by zero] for Custom data #153

Closed varungupta31 closed 2 years ago

varungupta31 commented 2 years ago

I created a det (.txt) file for my detections and trying to run the tracker using the file, but I'm getting the error:

File "sort/sort.py", line 327, in <module>
    print("Total Tracking took: %.3f seconds for %d frames or %.1f FPS" % (total_time, total_frames, total_frames / total_time))
ZeroDivisionError: float division by zero

The command i'm using to run the tracker:

python sort.py --phase train_custom --max_age 25 --min_hits 10

My det (.txt) file contents look like this:

2,-1,1291,957,55.27808,109.8432,0.812056,-1,-1,-1
3,-1,1291,957,55.4112,109.71791999999999,0.811765,-1,-1,-1
4,-1,1291,957,55.511039999999994,109.85040000000001,0.804608,-1,-1,-1
5,-1,1291,957,55.226879999999994,109.42992000000001,0.808499,-1,-1,-1
6,-1,1291,957,54.77888,108.84816000000001,0.822953,-1,-1,-1
7,-1,1291,958,55.144960000000005,108.68976,0.820582,-1,-1,-1

This det text file is located at sort/data/train_custom

I tried changing the line 327 in sort.py from print("Total Tracking took: %.3f seconds for %d frames or %.1f FPS" % (total_time, total_frames, total_frames / total_time)) to print("Total Tracking took: %.3f seconds for %d frames" % (total_time, total_frames)) this removes the ZeroDivisionError and I get the message: Total Tracking took: 0.000 seconds for 0 frames

but there is no output file generated.

Please help me out. @abewley @sodabeta7

cosimo17 commented 2 years ago

It seems that the code did not go into the for loop. So it took 0s and you got divzeroerror. Please debug the condition variable of the for loop. line290 and line299

varungupta31 commented 2 years ago

@cosimo17 Yes, the problem was with naming files in a certain way, as the main.py code is written that way. You either name the det files det.txtor modify the code that expects only det.txt files, I did the latter and solved the issue.