ultralytics / ultralytics

NEW - YOLOv8 🚀 in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
28.33k stars 5.63k forks source link

Training EV identificaiton model using YOLO v8 failure #15774

Open N1ISSET opened 2 weeks ago

N1ISSET commented 2 weeks ago

Search before asking

Question

Hi, my project is targeted to identify the EVs on the road. After I running the training file which is Script01.py it shows this failure. I am not sure what problem with my Profile01.yaml and Profile.py


Traceback (most recent call last):
  File "C:\Users\Dell\Downloads\ultralytics-main\Script001.py", line 6, in <module>
    model = YOLO("Profile.yaml")  # build a new model from scratch
            ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Dell\Downloads\ultralytics-main\ultralytics\models\yolo\model.py", line 23, in __init__
    super().__init__(model=model, task=task, verbose=verbose)
  File "C:\Users\Dell\Downloads\ultralytics-main\ultralytics\engine\model.py", line 140, in __init__
    self._new(model, task=task, verbose=verbose)
  File "C:\Users\Dell\Downloads\ultralytics-main\ultralytics\engine\model.py", line 260, in _new
    self.model = (model or self._smart_load("model"))(cfg_dict, verbose=verbose and RANK == -1)  # build model
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Dell\Downloads\ultralytics-main\ultralytics\nn\tasks.py", line 297, in __init__
    if self.yaml["backbone"][0][2] == "Silence":
       ~~~~~~~~~^^^^^^^^^^^^
KeyError: 'backbone'

Additional

Profile.py is attached below:

# Ultralytics YOLO 🚀, AGPL-3.0 license
# COCO8 dataset (first 8 images from COCO train2017) by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/detect/coco8/
# Example usage: yolo train data=coco8.yaml
# parent
# ├── ultralytics
# └── datasets
#     └── coco8  ← downloads here (1 MB)

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: C:\Users\Dell\Downloads\ultralytics-main\ultralytics-main\mydata\image # dataset root dir 数据集文件夹的相对路径
train: C:\Users\Dell\Downloads\ultralytics-main\ultralytics-main\mydata\image\train # train images (relative to 'path') 4 images
val: C:\Users\Dell\Downloads\ultralytics-main\ultralytics-main\mydata\image\val # val images (relative to 'path') 4 images
# 由于是该yaml配置文件是放在数据集文件夹中的,所以他使用的是相对路径 且train和val必须大于四张照片数据
test: C:\Users\Dell\Downloads\ultralytics-main\ultralytics-main\mydata\image\test # test images (optional)

# Classes 标签名称,替换成自己的
names:
  0: 室外电动车
  1: 室内电动车
Y-T-G commented 2 weeks ago

If it's a custom yaml model config, then it's missing the backbone key.

What's inside your Profile.yaml file?

N1ISSET commented 2 weeks ago

If it's a custom yaml model config, then it's missing the backbone key.

What's inside your Profile.yaml file?

sorry, that one is Profile.yaml, wrongly typed lol.

Y-T-G commented 2 weeks ago

You use the YOLO() function to load model. The data.yaml is supplied to model.train(), not YOLO().

https://docs.ultralytics.com/modes/train/