Describe the bug
The tracker crashes with a TypeError: 'float' object cannot be interpreted as an integer when the video frame rate (gui_param['frame_rate']) is a floating-point number. This happens because data_fps is passed as a margin to the find_last_number_segment_filled_range function, which then uses it in a range() constructor.
Error Traceback
Processing Frames: 5%|████▊ | 97/1999 [00:13<04:31, 7.01it/s]
Traceback (most recent call last):
File "/workspace/udmt/gui/tabs/create_training_dataset.py", line 305, in create_training_dataset
run_tracking(run_tracking_params)
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/run_tracker.py", line 125, in run_tracking
early_stop_flag = run_tracker(args.tracker_name, args.tracker_param, args.runid, args.dataset_name, seq_name, args.debug,
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/run_tracker.py", line 75, in run_tracker
early_stop_flag = run_dataset(sequence_obj, trackers, debug, threads, visdom_info=visdom_info,search_scale = search_scale,target_sz_bias = target_sz_bias,obj_id=obj_id,gui_param = gui_param)
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/evaluation/running.py", line 156, in run_dataset
early_stop_flag = run_sequence(seq, tracker_info, debug=debug, visdom_info=visdom_info,search_scale = search_scale,target_sz_bias = target_sz_bias, object_id=obj_id,gui_param = gui_param)
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/evaluation/running.py", line 108, in run_sequence
output, early_stop_flag = tracker.run_sequence(seq, debug=debug, visdom_info=visdom_info,search_scale = search_scale,target_sz_bias = target_sz_bias,gui_param = gui_param)
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/evaluation/tracker_multi.py", line 279, in run_sequence
output, early_stop_flag = self._track_sequence(tracker, seq, init_info, tracker_compensate = tracker_compensate,gui_param = gui_param)
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/evaluation/tracker_multi.py", line 674, in _track_sequence
current_loss_list = find_last_number_segment_filled_range(loss_list_mul[animal_id], margin=data_fps)
File "/workspace/udmt/gui/tabs/ST_Net/pytracking/evaluation/tracker_multi.py", line 115, in find_last_number_segment_filled_range
return list(range(int(desired_start_val), int(last_num) + 1))
TypeError: 'float' object cannot be interpreted as an integer
Code Analysis
In _track_sequence, data_fps can be assigned a float value:
# Around line 460
if gui_param['frame_rate'] >= 60:
data_fps = 60
elif gui_param['frame_rate'] >= 30:
data_fps = 30
else:
data_fps = gui_param['frame_rate'] # This could be a float (e.g., 24.5)
Then, it is used as the margin here:
# Around line 427
current_loss_list = find_last_number_segment_filled_range(..., margin=data_fps)
Inside find_last_number_segment_filled_range, the range() function fails because desired_start_val becomes a float:
# Around line 98
desired_start_val = start_val - margin
return list(range(desired_start_val, last_num + 1)) # Crash here
Suggested Fix
Ensure data_fps is explicitly cast to an int when derived from gui_param['frame_rate'].
# Revised code
if gui_param['frame_rate'] >= 60:
data_fps = 60
elif gui_param['frame_rate'] >= 30:
data_fps = 30
else:
data_fps = int(gui_param['frame_rate']) # Explicitly cast to int
Describe the bug
The tracker crashes with a
TypeError: 'float' object cannot be interpreted as an integerwhen the video frame rate (gui_param['frame_rate']) is a floating-point number. This happens becausedata_fpsis passed as amarginto thefind_last_number_segment_filled_rangefunction, which then uses it in arange()constructor.Error Traceback
Code Analysis
In
_track_sequence,data_fpscan be assigned a float value:Then, it is used as the
marginhere:Inside
find_last_number_segment_filled_range, therange()function fails becausedesired_start_valbecomes a float:Suggested Fix
Ensure
data_fpsis explicitly cast to anintwhen derived fromgui_param['frame_rate'].