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

Yolov8 Roboflow Notebook Error - Albumentations Package #311

Closed
1 of 2 tasks
Amir-Voloshin opened this issue Sep 19, 2024 · 5 comments
Closed
1 of 2 tasks

Yolov8 Roboflow Notebook Error - Albumentations Package #311

Amir-Voloshin opened this issue Sep 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Amir-Voloshin
Copy link

Amir-Voloshin commented Sep 19, 2024

Search before asking

  • I have searched the Roboflow Notebooks issues and found no similar bug report.

Notebook name

Notebook: YOLOv8 Object Detection

Bug

When beginning training on the first epoch, this unhashable type error arises:
Traceback (most recent call last): File "/usr/local/bin/yolo", line 8, in <module> sys.exit(entrypoint()) File "/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/__init__.py", line 445, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/model.py", line 341, in train self.trainer.train() File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/trainer.py", line 191, in train self._do_train(world_size) File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/trainer.py", line 325, in _do_train for i, batch in pbar: File "/usr/local/lib/python3.10/dist-packages/tqdm/std.py", line 1181, in __iter__ for obj in iterable: File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/build.py", line 42, in __iter__ yield next(self.iterator) File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 630, in __next__ data = self._next_data() File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 1344, in _next_data return self._process_data(data) File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/dataloader.py", line 1370, in _process_data data.reraise() File "/usr/local/lib/python3.10/dist-packages/torch/_utils.py", line 706, in reraise raise exception TypeError: Caught TypeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/worker.py", line 309, in _worker_loop data = fetcher.fetch(index) # type: ignore[possibly-undefined] File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py", line 52, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/base.py", line 242, in __getitem__ return self.transforms(self.get_image_and_label(index)) File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/augment.py", line 70, in __call__ data = t(data) File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/augment.py", line 824, in __call__ new = self.transform(image=im, bboxes=bboxes, class_labels=cls) # transformed File "/usr/local/lib/python3.10/dist-packages/albumentations/core/composition.py", line 334, in __call__ self.preprocess(data) File "/usr/local/lib/python3.10/dist-packages/albumentations/core/composition.py", line 368, in preprocess p.preprocess(data) File "/usr/local/lib/python3.10/dist-packages/albumentations/core/utils.py", line 125, in preprocess data = self.add_label_fields_to_data(data) File "/usr/local/lib/python3.10/dist-packages/albumentations/core/utils.py", line 185, in add_label_fields_to_data encoded_labels = encoder.fit_transform(data[label_field]) File "/usr/local/lib/python3.10/dist-packages/albumentations/core/utils.py", line 60, in fit_transform self.fit(y) File "/usr/local/lib/python3.10/dist-packages/albumentations/core/utils.py", line 48, in fit unique_labels = sorted(set(y)) TypeError: unhashable type: 'numpy.ndarray'

Environment

  • Google Colab
  • Ultralytics YOLOv8.0.196 🚀 Python-3.10.12 torch-2.4.1+cu121 CUDA:0 (Tesla T4, 15102MiB)
    Setup complete ✅ (2 CPUs, 12.7 GB RAM, 32.6/112.6 GB disk)

Minimal Reproducible Example

%cd {HOME}

!yolo task=detect mode=train model=yolov8s.pt data={dataset.location}/data.yaml epochs=300 imgsz=640 plots=True

Additional

Ran the notebook tutorial, importing my own dataset from roboflow (tried several datasets), under "Custom Training" this error occurs each time.

Last successful training used torch 2.4.0, currently torch 2.4.1 is being loaded.

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@Amir-Voloshin Amir-Voloshin added the bug Something isn't working label Sep 19, 2024
@LinasKo
Copy link
Contributor

LinasKo commented Sep 20, 2024

This is an issue with ultralytics or albumentations.

Could you please try the following?
pip install albumentations==1.4

(based on a similar issue)

@Amir-Voloshin
Copy link
Author

Hi @LinasKo ,
pip install albumentations==1.4
did not work. Any other suggestions?

@LinasKo
Copy link
Contributor

LinasKo commented Sep 20, 2024

I wasn't sure it would, but I tried it and it did help get the training going: Colab. Note that I added the !pip install albumentations==1.4 right before the training starts, ensuring it is the final dependency to be installed.

@Amir-Voloshin
Copy link
Author

@LinasKo adding it right before training works! Thank you.

@LinasKo
Copy link
Contributor

LinasKo commented Sep 20, 2024

Glad to help! 😉

@LinasKo LinasKo closed this as completed Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants