yangchris11 / samurai

Official repository of "SAMURAI: Adapting Segment Anything Model for Zero-Shot Visual Tracking with Motion-Aware Memory"
https://yangchris11.github.io/samurai/
Apache License 2.0
4.68k stars 247 forks source link

How to deal with IndexError: list index out of range #26

Closed liumingzs closed 33 minutes ago

liumingzs commented 1 day ago

(SAMURAI) ubuntu@ubun:/data3/ZS/samurai$ python scripts/demo.py --video_path car.mp4 --txt_path txt.txt SAMURAI mode: True Traceback (most recent call last): File "/data3/ZS/samurai/scripts/demo.py", line 120, in main(args) File "/data3/ZS/samurai/scripts/demo.py", line 46, in main prompts = load_txt(args.txt_path) File "/data3/ZS/samurai/scripts/demo.py", line 19, in load_txt x, y, w, h = map(float, line.split(',')) ValueError: could not convert string to float: '236 141 400 350' (SAMURAI) ubuntu@ubun:/data3/ZS/samurai$ python scripts/demo.py --video_path car.mp4 --txt_path txt.txt SAMURAI mode: True /data3/ZS/samurai/./sam2/sam2/sam2_video_predictor.py:961: UserWarning: cannot import name '_C' from 'sam2' (/data3/ZS/samurai/./sam2/sam2/init.py)

Skipping the post-processing step due to the error above. You can still use SAM 2 and it's OK to ignore the error above, although some post-processing functionality may be limited (which doesn't affect the results in most cases; see https://github.com/facebookresearch/sam2/blob/main/INSTALL.md). pred_masks_gpu = fill_holes_in_mask_scores( propagate in video: 100%|██████████████████████████████████████████████████████▉| 8113/8114 [06:23<00:00, 21.15it/s] Traceback (most recent call last): File "/data3/ZS/samurai/scripts/demo.py", line 120, in main(args) File "/data3/ZS/samurai/scripts/demo.py", line 93, in main img = loaded_frames[frame_idx] IndexError: list index out of range

yangchris11 commented 15 hours ago

Look like a mismatch between the number of frames and the actual number of images in the given folder. Can you check if you have the correct naming of these images?

zhyjiang commented 15 hours ago
x, y, w, h = map(float, line.split(','))
ValueError: could not convert string to float: '236 141 400 350'

Please refer to our README, the bbox should be 236,141,400,350

Note: The .txt file contains a single line with the bounding box of the first frame in x,y,w,h format.

The list out of index may happen if the images are not in jpg format.

liumingzs commented 6 hours ago

thanks for your answer