DAMO-NLP-SG / VideoLLaMA2

VideoLLaMA 2: Advancing Spatial-Temporal Modeling and Audio Understanding in Video-LLMs
Apache License 2.0
716 stars 48 forks source link

UnboundLocalError: local variable "video_path" referenced before assigment #82

Open acDante opened 2 weeks ago

acDante commented 2 weeks ago

Hi, I am trying to replicate your experiments on ActivityNet using VideoLLaMA2-7B model on a single A100 GPU. Here is the command I run:

python videollama2/eval/inference_video_oqa_activitynet.py --model-path DAMO-NLP-SG/VideoLLaMA2-7B --video-folder eval/Activitynet_Zero_Shot_QA/all_test/ --question-file eval/Activitynet_Zero_Shot_QA/test_q.json --answer-file eval/Activitynet_Zero_Shot_QA/test_a.json --output-file eval_output/Activitynet_Zero_Shot_QA/answers/VideoLLaMA2-7B/pred.json --num-chunks 1 --chunk-idx 0 --num-workers 1

I got the following error when running the inference script:

Traceback (most recent call last):
  File "/mnt/ceph_rbd/VideoLLaMA2/videollama2/eval/inference_video_oqa_activitynet.py", line 148, in <module>
    run_inference(args)
  File "/mnt/ceph_rbd/VideoLLaMA2/videollama2/eval/inference_video_oqa_activitynet.py", line 105, in run_inference
    for i, (video_tensors, video_names, questions, question_ids, answers) in enumerate(tqdm(dataloader)):
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/tqdm/std.py", line 1181, in __iter__
    for obj in iterable:
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 631, in __next__
    data = self._next_data()
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1346, in _next_data
    return self._process_data(data)
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1372, in _process_data
    data.reraise()
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/_utils.py", line 722, in reraise
    raise exception
UnboundLocalError: Caught UnboundLocalError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/mnt/ceph_rbd/miniconda3/envs/videollama2/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/mnt/ceph_rbd/VideoLLaMA2/videollama2/eval/inference_video_oqa_activitynet.py", line 64, in __getitem__
    print("video path: ", video_path)
UnboundLocalError: local variable 'video_path' referenced before assignment

Could you help troubleshoot this issue?

clownrat6 commented 2 weeks ago

Please check if the position of the video folder actually have the video file. If the video file is not existed, the video_path variable is not initialized, which causes this error.

acDante commented 2 weeks ago

Thanks for your reply! I have already put all the 500 test videos in the specified path but still have this issue.

clownrat6 commented 1 week ago

Hi! Can you attempt the new inference script in the latest commit. It prints some debug string, which may help you solve this issue.