Yolo 11 nano 数据集结构不正确

问题描述 投票:0回答:1

我是 Yolo 的新手,第一次尝试构建我的数据库。这就是我的目录的结构。

 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 

当我在 YOLO_Project_name.ipynb 中运行以下单元格时:

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

我收到以下错误。

错误信息

---------------------------------------------------------------------------
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)

我哪里出错了,这个错误消息是什么意思?该项目旨在识别单个类别的对象(不是模型预先训练的对象)并将其定位在框架内。

python object-detection yolo training-data
1个回答
0
投票

我认为你的 yaml 文件有问题。你能展示一下它是什么样子吗?它应该像下面这样:

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
© www.soinside.com 2019 - 2024. All rights reserved.