transformers icon indicating copy to clipboard operation
transformers copied to clipboard

Video Classification Task Guide Using Undeclared Variables

Open astern21 opened this issue 1 year ago • 0 comments

System Info

  • transformers version: 4.32.1
  • Platform: macOS-10.16-x86_64-i386-64bit
  • Python version: 3.11.4
  • Huggingface_hub version: 0.17.2
  • Safetensors version: 0.3.2
  • Accelerate version: 0.24.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.0.1 (False)
  • Tensorflow version (GPU?): 2.13.0 (False)
  • Flax version (CPU?/GPU?/TPU?): 0.7.4 (cpu)
  • Jax version: 0.4.16
  • JaxLib version: 0.4.16
  • Using GPU in script?: No
  • Using distributed or parallel set-up in script?: No

Who can help?

@amyeroberts

Information

  • [X] The official example scripts
  • [ ] My own modified scripts

Tasks

  • [X] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [ ] My own task or dataset (give details below)

Reproduction

  1. Follow the Video Classification example in the HuggingFace docs: https://huggingface.co/docs/transformers/tasks/video_classification

  2. When Reaching the step

`class_labels = sorted({str(path).split("/")[2] for path in all_video_file_paths}) label2id = {label: i for i, label in enumerate(class_labels)} id2label = {i: label for label, i in label2id.items()}

print(f"Unique classes: {list(label2id.keys())}.") `

The variable all_video_file_paths is not previously defined in the example docs. I had to write a function to retrieve the video file paths myself, as seen below:

`import os

dataset_path = "UCF101_subset"

all_video_file_paths = []

for split in ["train", "val", "test"]: split_path = os.path.join(dataset_path, split) for category in os.listdir(split_path): category_path = os.path.join(split_path, category) for video_file in os.listdir(category_path): video_file_path = os.path.join(category_path, video_file) all_video_file_paths.append(video_file_path)`

  1. When preparing the dataset for training, the variable dataset_root_path is not previously defined.

Expected behavior

I assume that these variables should have been previously defined to not cause errors for people following the example docs.

astern21 avatar Mar 22 '24 19:03 astern21