Closed subwheel closed 1 month ago
I also have the same problem.
It seems like it is related to library compatibility, as everything works fine if you use the latest version of all libraries, but with older version(as in my case, with ultralytics==8.0.114) you get this error
!pip install albumentations==1.4
Thanks @galang006. Your solution works like a charm!
CLEAR EXPLAINATION: @subwheel The error you're encountering during your YOLO training, specifically the "TypeError: unhashable type: 'numpy.ndarray'," suggests a problem with how your dataset is being processed, likely related to the format of your labels or bounding boxes. To resolve this, first ensure that your dataset is in the correct format expected by YOLO, where each image has a corresponding label file with bounding box coordinates and class labels formatted correctly. If you've implemented any data augmentation techniques, verify that they are compatible with the input data types, as mismatches can lead to errors. Consider reverting any recent changes to your training configuration, including modifications to epochs or other hyperparameters, especially since the code worked successfully in previous attempts. Additionally, check for library version compatibility and clear any cached datasets or models that might be causing conflicts. If you're still having trouble, running your code on the CPU instead of the GPU might provide more informative error messages. Lastly, ensure that your label files contain lines formatted as "class_id center_x center_y width height," with normalized values between 0 and 1 for proper processing. By addressing these aspects, you should be able to resolve the issue and continue training effectively.
@sriramsowmithri9807 @galang006 Thanks for the help! My code can now run successfully!
!pip install albumentations==1.4
Thanks, it actually worked!
should it be installed before ultralytics ?
Thanks guys ! it worked for me too - installed albumentations==1.4 before ultralytics !
But this this is problematic, we don't really know which version of ultralytics works with which version of a albumentations. I'm saying this because the notebook worked fine a couple of days ago without !pip install albumentations==1.4
!
Thanks to @galang006
Thanks so much @galang006
Thanks so much @galang006. You are a lifesaver.
I used to work on ultralytics 8.2.50 and albumentations 1.4.11, then I updated both, my notebook stopped working like it did for all of you. Then I downgraded both ultralytics and albumentations with pip install -U ultralytics==8.2.50 albumentations==1.4.11 but when I run the scripts, yolov8 doesn't detect albumentations (as if it isn't installed), when I try albumentations==1.4 it does get detected again, but I'd prefer having 1.4.11 which includes some changes. Any ideas?
!pip install albumentations==1.4
its work chef thanks alot
!pip install albumentations==1.4
Thanks man !
Thanks to @galang006
!pip install albumentations==1.4
Thank you!
When I was training my own custom dataset, I used Google Colab. At the first two attempt, my code runs successfully. My code is: !yolo task=detect mode=train epochs=240 batch=12 plots=True model=weights/yolov10x.pt data=data.yaml device=0 But when I tried to execute the code the third time, while I only modified my epoch, some error code was reported:
Epoch GPU_mem box_om cls_om dfl_om box_oo cls_oo dfl_oo Instances Size 0% 0/485 [00:00<?, ?it/s] Traceback (most recent call last): File "/usr/local/bin/yolo", line 8, in
sys.exit(entrypoint())
File "/usr/local/lib/python3.10/dist-packages/ultralytics/cfg/init.py", line 594, in entrypoint
getattr(model, mode)(**overrides) # default args from model
File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/model.py", line 657, in train
self.trainer.train()
File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/trainer.py", line 213, in train
self._do_train(world_size)
File "/usr/local/lib/python3.10/dist-packages/ultralytics/engine/trainer.py", line 363, 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 49, 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
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/base.py", line 253, in getitem
return self.transforms(self.get_image_and_label(index))
File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/augment.py", line 74, in call
data = t(data)
File "/usr/local/lib/python3.10/dist-packages/ultralytics/data/augment.py", line 866, 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'
I barely change anything compared to the previous attempts, why those attempts were able to execute but not this time? How should I fix this problem?