transformers: ValueError: Task image-classification is not compatible with this dataset! Available tasks: []

System Info

Dear all,

Thank you for your great work. I have tried to run image-classification example on my simple dataset and I got this error. The version of transformers I used is the newest one. Do you have any idea what happened?

Thanks very much!

WARNING:datasets.builder:Found cached dataset imagefolder (/root/.cache/huggingface/datasets/imagefolder/default-9107176dcf18ce11/0.0.0/e872d3ec27c6c200a8881a4af52930df7eca3372b19aa4d0f5db74a2fded8141)
100% 1/1 [00:00<00:00, 45.80it/s]
Traceback (most recent call last):
  File "run_image_classification.py", line 388, in <module>
    main()
  File "run_image_classification.py", line 240, in main
    task="image-classification",
  File "/usr/local/lib/python3.7/dist-packages/datasets/load.py", line 1713, in load_dataset
    ds = ds.prepare_for_task(task)
  File "/usr/local/lib/python3.7/dist-packages/datasets/dataset_dict.py", line 1272, in prepare_for_task
    return DatasetDict({k: dataset.prepare_for_task(task=task, id=id) for k, dataset in self.items()})
  File "/usr/local/lib/python3.7/dist-packages/datasets/dataset_dict.py", line 1272, in <dictcomp>
    return DatasetDict({k: dataset.prepare_for_task(task=task, id=id) for k, dataset in self.items()})
  File "/usr/local/lib/python3.7/dist-packages/datasets/arrow_dataset.py", line 2172, in prepare_for_task
    f"Task {task} is not compatible with this dataset! Available tasks: {list(unique_values(tasks))}"
ValueError: Task image-classification is not compatible with this dataset! Available tasks: []

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

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

Reproduction

!CUDA_DIVISIBLE_DEVICES=0, python3 run_image_classification.py
–model_name_or_path facebook/convnext-tiny-224
–train_dir $TRAIN_DIR
–output_dir $OUTPUT_DIR
–do_train
–do_eval
–learning_rate 1e-5
–num_train_epochs 10
–per_device_train_batch_size 16
–per_device_eval_batch_size 16
–logging_strategy steps
–logging_steps 10
–evaluation_strategy epoch
–save_strategy epoch
–load_best_model_at_end True
–save_total_limit 3
–seed 1337
–overwrite_output_dir

Expected behavior

ValueError: Task image-classification is not compatible with this dataset! Available tasks: []

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (9 by maintainers)

Most upvoted comments

Solved it by downgrading to datasets==2.4.0

The issue seems to persist. Is there any solution for this? prepare_for_task() is not called from run_image_classification.py (at least in the current version) @lhoestq

I don’t think so, but the list is available here: https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts

Anyway for the next release I think we need to still have the known_task_ids variable, otherwise it makes evaluate crash.

Do you think you could fix this on the evaluate side and do a release ? Otherwise we can also re-add this list temporarily

Hi! We still need to make a patch release on the datasets side for my fix to take effect. In the meantime, you can install datasets directly from main:

pip install git+https://github.com/huggingface/datasets.git