[BUG] KeyError: 'target' in Image Classification - autotrain-advanced Colab
Theivaprakasham opened this issue ยท 8 comments
Prerequisites
- I have read the documentation.
- I have checked other issues for similar problems.
Backend
Colab
Interface Used
UI
CLI Command
No response
UI Screenshots & Parameters
Error Logs
Training is starting... Please wait!
INFO | 2024-09-30 11:48:29 | autotrain.cli.autotrain:main:60 - Using AutoTrain configuration: config.yml
INFO | 2024-09-30 11:48:29 | autotrain.parser:post_init:148 - Running task: image_multi_class_classification
INFO | 2024-09-30 11:48:29 | autotrain.parser:post_init:149 - Using backend: local
WARNING | 2024-09-30 11:48:29 | autotrain.trainers.common:init:180 - Parameters supplied but not used: image, label
INFO | 2024-09-30 11:48:29 | autotrain.parser:run:212 - {'data_path': '/content/dummy', 'model': 'microsoft/resnet-50', 'username': None, 'lr': 5e-05, 'epochs': 3, 'batch_size': 8, 'warmup_ratio': 0.1, 'gradient_accumulation': 1, 'optimizer': 'adamw_torch', 'scheduler': 'linear', 'weight_decay': 0.0, 'max_grad_norm': 1.0, 'seed': 42, 'train_split': 'train', 'valid_split': None, 'logging_steps': -1, 'project_name': 'autotrain-m82sg-85s3j', 'auto_find_batch_size': False, 'mixed_precision': 'fp16', 'save_total_limit': 1, 'token': None, 'push_to_hub': True, 'eval_strategy': 'epoch', 'image_column': 'image', 'target_column': 'target', 'log': 'tensorboard', 'early_stopping_patience': 5, 'early_stopping_threshold': 0.01}
INFO | 2024-09-30 11:48:29 | autotrain.backends.local:create:8 - Starting local training...
INFO | 2024-09-30 11:48:29 | autotrain.commands:launch_command:501 - ['accelerate', 'launch', '--num_machines', '1', '--num_processes', '1', '--mixed_precision', 'fp16', '-m', 'autotrain.trainers.image_classification', '--training_config', 'autotrain-m82sg-85s3j/training_params.json']
INFO | 2024-09-30 11:48:29 | autotrain.commands:launch_command:502 - {'data_path': '/content/dummy', 'model': 'microsoft/resnet-50', 'username': None, 'lr': 5e-05, 'epochs': 3, 'batch_size': 8, 'warmup_ratio': 0.1, 'gradient_accumulation': 1, 'optimizer': 'adamw_torch', 'scheduler': 'linear', 'weight_decay': 0.0, 'max_grad_norm': 1.0, 'seed': 42, 'train_split': 'train', 'valid_split': None, 'logging_steps': -1, 'project_name': 'autotrain-m82sg-85s3j', 'auto_find_batch_size': False, 'mixed_precision': 'fp16', 'save_total_limit': 1, 'token': None, 'push_to_hub': True, 'eval_strategy': 'epoch', 'image_column': 'image', 'target_column': 'target', 'log': 'tensorboard', 'early_stopping_patience': 5, 'early_stopping_threshold': 0.01}
The following values were not passed to accelerate launch
and had defaults used instead:
--dynamo_backend
was set to a value of 'no'
To avoid this warning pass in values for each of the problematic parameters or run accelerate config
.
INFO:albumentations.check_version:A new version of Albumentations is available: 1.4.16 (you have 1.4.7). Upgrade using: pip install --upgrade albumentations
INFO | 2024-09-30 11:48:41 | main๐82 - Train data: Dataset({
features: ['image', 'label'],
num_rows: 374
})
INFO | 2024-09-30 11:48:41 | main๐83 - Valid data: None
ERROR | 2024-09-30 11:48:41 | autotrain.trainers.common:wrapper:120 - train has failed due to an exception: Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/autotrain/trainers/common.py", line 117, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/autotrain/trainers/image_classification/main.py", line 85, in train
classes = train_data.features[config.target_column].names
KeyError: 'target'
ERROR | 2024-09-30 11:48:41 | autotrain.trainers.common:wrapper:121 - 'target'
INFO | 2024-09-30 11:48:42 | autotrain.parser:run:217 - Job ID: 6923
Training completed successfully!
Additional Information
I am trying to train a image classification model using a dataset of 5 classes. However, I'm receiving a KeyError: 'target' error while starting to train. I have followed the dataset structure as mentioned in the Documentation.
Config:
{
"lr": 5e-05,
"epochs": 3,
"batch_size": 8,
"warmup_ratio": 0.1,
"gradient_accumulation": 1,
"optimizer": "adamw_torch",
"scheduler": "linear",
"weight_decay": 0.0,
"max_grad_norm": 1.0,
"seed": 42,
"logging_steps": -1,
"auto_find_batch_size": false,
"mixed_precision": "fp16",
"save_total_limit": 1,
"eval_strategy": "epoch",
"early_stopping_patience": 5,
"early_stopping_threshold": 0.01,
"push_to_hub": true
}
how does the dataset look like?
how does the dataset look like?
/content/dummy
โโโ Aglais_io
โ โโโ 20240210230338280122_large.jpg
โ โโโ 20240210230338437501_large.jpg
โ โโโ 20240210230338679894_large.jpeg
โ โโโ 20240210230338859195_large.jpeg
โ โโโ 20240210230339371897_large.jpeg
โ โโโ 20240210230339481055_large.jpeg
...........
โโโ Anthocharis_cardamines
โ โโโ 20240210230356269418_large.jpg
โ โโโ 20240210230356624279_large.jpg
โ โโโ 20240210230356792814_large.jpg
โ โโโ 20240210230356861192_large.jpg
โ โโโ 20240210230357034893_large.jpeg
โ โโโ 20240210230357081746_large.jpeg
........
......
โโโ Argynnis_pandora
โโโ 20240210230426055731_large.jpg
โโโ 20240210230426075113_large.JPG
โโโ 20240210230426142114_large.jpg
โโโ 20240210230426332549_large.jpg
โโโ 20240210230426976274_large.jpg
6 directories, 374 files
could you please try this colab instead: https://colab.research.google.com/github/huggingface/autotrain-advanced/blob/main/colabs/image_classification.ipynb ?
could you please try this colab instead: https://colab.research.google.com/github/huggingface/autotrain-advanced/blob/main/colabs/image_classification.ipynb ?
I tried running this colab. I got this error.
ERROR | 2024-09-30 12:50:52 | autotrain.trainers.common:wrapper:120 - train has failed due to an exception: Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/autotrain/trainers/common.py", line 117, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/autotrain/trainers/image_classification/main.py", line 85, in train
classes = train_data.features[config.target_column].names
KeyError: 'labels'ERROR | 2024-09-30 12:50:52 | autotrain.trainers.common:wrapper:121 - 'labels'
INFO | 2024-09-30 12:50:54 | autotrain.parser:run:217 - Job ID: 3343
However, I just changed this
column_mapping: # do not change
image_column: image
target_column: labels
to
target_column: label
And this Colab works seamlessly now.
ohh. ill fix it and publish task specific colabs. the colab ui is quite un-maintainable. thank you for letting me know.
ohh. ill fix it and publish task specific colabs. the colab ui is quite un-maintainable. thank you for letting me know.
Thank you! Cheers.. Have a good day!
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 20 days since being marked as stale.