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 Tags=8.2 model = YOLO(model='yolov8n.yaml') error occurred #12688

Open
1 of 2 tasks
dzz-gg opened this issue May 14, 2024 · 1 comment
Open
1 of 2 tasks

yolov8 Tags=8.2 model = YOLO(model='yolov8n.yaml') error occurred #12688

dzz-gg opened this issue May 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dzz-gg
Copy link

dzz-gg commented May 14, 2024

Search before asking

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

YOLOv8 Component

Predict

Bug

from ultralytics import YOLO

model = YOLO(model='yolov8n.yaml')

The official model loading code cannot be run
The following error message is displayed:
Traceback (most recent call last):
File "D:\Project\ultralytics-main\vedio.py", line 1, in
from ultralytics import YOLO
File "D:\Project\ultralytics-main\ultralytics_init_.py", line 5, in
from ultralytics.data.explorer.explorer import Explorer
File "D:\Project\ultralytics-main\ultralytics\data_init_.py", line 3, in
from .base import BaseDataset
File "D:\Project\ultralytics-main\ultralytics\data\base.py", line 17, in
from ultralytics.data.utils import FORMATS_HELP_MSG, HELP_URL, IMG_FORMATS
File "D:\Project\ultralytics-main\ultralytics\data\utils.py", line 19, in
from ultralytics.nn.autobackend import check_class_names
File "D:\Project\ultralytics-main\ultralytics\nn_init_.py", line 3, in
from .tasks import (
File "D:\Project\ultralytics-main\ultralytics\nn\tasks.py", line 10, in
from ultralytics.nn.modules import (
File "D:\Project\ultralytics-main\ultralytics\nn\modules_init_.py", line 65, in
from .head import OBB, Classify, Detect, Pose, RTDETRDecoder, Segment, WorldDetect
File "D:\Project\ultralytics-main\ultralytics\nn\modules\head.py", line 10, in
from ultralytics.utils.tal import TORCH_1_10, dist2bbox, dist2rbox, make_anchors
File "D:\Project\ultralytics-main\ultralytics\utils_init_.py", line 401, in
DEFAULT_CFG_DICT = yaml_load(DEFAULT_CFG_PATH)
File "D:\Project\ultralytics-main\ultralytics\utils_init_.py", line 379, in yaml_load
data = yaml.safe_load(s) or {} # always return a dict (yaml.safe_load() may return None for empty files)
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml_init_.py", line 125, in safe_load
return load(stream, SafeLoader)
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml_init_.py", line 81, in load
return loader.get_single_data()
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\constructor.py", line 49, in get_single_data
node = self.get_single_node()
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\composer.py", line 36, in get_single_node
document = self.compose_document()
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\composer.py", line 55, in compose_document
node = self.compose_node(None, None)
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\composer.py", line 84, in compose_node
node = self.compose_mapping_node(anchor)
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\composer.py", line 127, in compose_mapping_node
while not self.check_event(MappingEndEvent):
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\parser.py", line 98, in check_event
self.current_event = self.state()
File "D:\Anaconda\envs\yolov8\lib\site-packages\yaml\parser.py", line 438, in parse_block_mapping_key
raise ParserError("while parsing a block mapping", self.marks[-1],
yaml.parser.ParserError: while parsing a block mapping
in "", line 4, column 1:
task: detect # (str) YOLO task, ...
^
expected , but found ''
in "", line 8, column 3:
gs ----------------------------- ...
^

Environment

Ultralytics YOLOv8.2.12 🚀 Python-3.8.19 torch-2.0.1 CUDA:0 (NVIDIA GeForce RTX 3060 Laptop GPU, 6144MiB)
Setup complete ✅ (20 CPUs, 31.7 GB RAM, 131.1/742.2 GB disk)

OS Windows-10-10.0.19045-SP0
Environment Windows
Python 3.8.19
Install pip
RAM 31.69 GB
CPU 12th Gen Intel Core(TM) i7-12700H
CUDA 11.7

matplotlib ✅ 3.7.5>=3.3.0
opencv-python ✅ 4.9.0.80>=4.6.0
pillow ✅ 10.3.0>=7.1.2
pyyaml ✅ 6.0.1>=5.3.1
requests ✅ 2.31.0>=2.23.0
scipy ✅ 1.10.1>=1.4.1
torch ✅ 2.0.1>=1.8.0
torchvision ✅ 0.15.2>=0.9.0
tqdm ✅ 4.66.4>=4.64.0
psutil ✅ 5.9.8
py-cpuinfo ✅ 9.0.0
thop ✅ 0.1.1-2209072238>=0.1.1
pandas ✅ 2.0.3>=1.1.4
seaborn ✅ 0.13.2>=0.11.0

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@dzz-gg dzz-gg added the bug Something isn't working label May 14, 2024
@glenn-jocher
Copy link
Member

Hello! It looks like you're encountering a YAML parsing error when trying to load the model configuration. This error typically occurs due to syntax issues in the YAML file. Here are a couple of steps you can take to resolve this:

  1. Check YAML Syntax: Ensure that the yolov8n.yaml file is correctly formatted. Pay close attention to indentation levels, as YAML is sensitive to spaces and tabs.

  2. Validate YAML File: You can use online tools like yamlvalidator.com to check if there are any syntax errors in your YAML file.

  3. Example Code: Here's how you should typically load a YOLOv8 model:

    from ultralytics import YOLO
    
    # Load a pretrained model
    model = YOLO('yolov8n.pt')

If the issue persists after checking the YAML file, it might be helpful to share the contents of yolov8n.yaml so we can take a closer look. Let me know how it goes! 😊

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