Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
acDante opened this issue Aug 29, 2024 · 3 comments
Closed

Comments

@acDante
Copy link

acDante commented Aug 29, 2024

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
Copy link
Member

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
Copy link
Author

acDante commented Aug 30, 2024

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

@clownrat6
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants