4-4
4-4

Reputation: 15

Yolo 11 nano dataset structured incorrectly

I'm new to working with Yolo and trying for the first time to structure my database. This is how my directory is structured.

 Project_Name/
├── datasets/
│   ├── images/
│   │   ├── train/               
│   │   └── val/                 
│   ├── labels/
│   │   ├── train/               
│   │   │   ├── 000000000009.txt
│   │   │   ├── 000000000025.txt
│   │   │   ├── 000000000034.txt
│   │   └── val/                 
│   │       ├── 000000000030.txt
│   │   └── train.cache          
├── raw_set/
│   ├── images/                  # Data which i separate into test and val
│   └── labels/                  
├── gate.yaml                    
├── runs/                        
├── pat.txt                      
├── YOLO_Project_name.ipynb       
└── yolo11n.pt 

When I run the following cell in YOLO_Project_name.ipynb:

model = YOLO("yolo11n.pt")
results = model.train(data="datasets/gate.yaml", epochs=5, imgsz=640, device="mps")

I get the following error.

Error Message

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[58], line 2
      1 model = YOLO("yolo11n.pt")
----> 2 results = model.train(data="datasets/gate.yaml", epochs=5, imgsz=640, device="mps")

File ~/Library/Python/3.11/lib/python/site-packages/ultralytics/engine/model.py:802, in Model.train(self, trainer, **kwargs)
    799     self.model = self.trainer.model
    801 self.trainer.hub_session = self.session  # attach optional HUB session
--> 802 self.trainer.train()
    803 # Update model and cfg after training
    804 if RANK in {-1, 0}:

File ~/Library/Python/3.11/lib/python/site-packages/ultralytics/engine/trainer.py:207, in BaseTrainer.train(self)
    204         ddp_cleanup(self, str(file))
    206 else:
--> 207     self._do_train(world_size)

File ~/Library/Python/3.11/lib/python/site-packages/ultralytics/engine/trainer.py:327, in BaseTrainer._do_train(self, world_size)
    325 if world_size > 1:
    326     self._setup_ddp(world_size)
--> 327 self._setup_train(world_size)
    329 nb = len(self.train_loader)  # number of batches
    330 nw = max(round(self.args.warmup_epochs * nb), 100) if self.args.warmup_epochs > 0 else -1  # warmup iterations
...
    165         f"len(boxes) = {len_boxes}. To resolve this only boxes will be used and all segments will be removed. "
    166         "To avoid this please supply either a detect or segment dataset, not a detect-segment mixed dataset."
    167     )

ValueError: not enough values to unpack (expected 3, got 0)

Where am I going wrong here, what does this error message mean? The project is meant to identify objects of a single class (not one the model was pre-trained on) and locate it within the frame.

Upvotes: 0

Views: 237

Answers (1)

Ariya
Ariya

Reputation: 76

I think there is something wrong with your yaml file.Can you show what it looks like? it should be something like below:

path: /home/user/Projects/deep/yolo-torch-2/yolov8 # dataset root dir
train: images/train # train images (relative to 'path')
val: images/val # val images (relative to 'path') 
test: # test images (optional)

# Classes
names:
  0: class1
  1: class2
  2: class3
  3: class4

Upvotes: 2

Related Questions