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

use yolov8-rtdetr.yaml show error #5272

Closed
1 task done
baoyuchen opened this issue Oct 8, 2023 · 14 comments
Closed
1 task done

use yolov8-rtdetr.yaml show error #5272

baoyuchen opened this issue Oct 8, 2023 · 14 comments
Labels
question Further information is requested Stale Stale and schedule for closing soon

Comments

@baoyuchen
Copy link

Search before asking

Question

Traceback (most recent call last):
File "E:\fourworkplace\ultralytics-main\ultralytics\engine\model.py", line 428, in _smart_load
return self.task_map[self.task][key]
KeyError: None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "E:\fourworkplace\ultralytics-main\demo1.py", line 3, in
model = YOLO("E:/fourworkplace/ultralytics-main/ultralytics/cfg/models/v8/yolov8-rtdetr.yaml") # build a new model from scratch
File "E:\fourworkplace\ultralytics-main\ultralytics\engine\model.py", line 97, in init
self._new(model, task)
File "E:\fourworkplace\ultralytics-main\ultralytics\engine\model.py", line 133, in _new
self.model = (model or self._smart_load('model'))(cfg_dict, verbose=verbose and RANK == -1) # build model
File "E:\fourworkplace\ultralytics-main\ultralytics\engine\model.py", line 433, in _smart_load
raise NotImplementedError(
NotImplementedError: WARNING 'YOLO' model does not support '_new' mode for 'None' task yet.

the code as follow
from ultralytics import YOLO

Load a model

model = YOLO("E:/fourworkplace/ultralytics-main/ultralytics/cfg/models/v8/yolov8-rtdetr.yaml") # build a new model from scratch
model.info()

Additional

q

@baoyuchen baoyuchen added the question Further information is requested label Oct 8, 2023
@github-actions
Copy link

github-actions bot commented Oct 8, 2023

👋 Hello @baoyuchen, thank you for your interest in YOLOv8 🚀! We recommend a visit to the YOLOv8 Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@baoyuchen hello, and thank you for bringing this issue to our attention. It looks like there's a KeyError and NotImplementedError produced when trying to create a YOLO model with the YOLOv8-rtDETR.yaml configuration file.

These errors may suggest that the task parameter in the function call _new(model, task) is not specified, resulting in a KeyError when the function _smart_load(key) tries to map the task, and subsequently produces a NotImplementedError since the 'None' task cannot be found.

When using the YOLO constructor to create a new model, and specifically in the context of the RT-DETR task, remember to provide additional necessary parameters and information in the correct format within the yaml file. Please ensure all fields in the yaml file are properly filled out and the task you intend to perform is correctly specified.

Remember to keep your Ultralytics YOLOv8 repository updated, as we constantly strive to improve user experience by fixing bugs and adding new features. Should the issue persist, please continue to share as much detail about the bug as possible, including Python version, operating system, and any additional stack trace or error messages, to help us find out what's going wrong.

Hope this helps. Let me know if you have any other questions.

Copy link

github-actions bot commented Nov 8, 2023

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Nov 8, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2023
@nzbanana
Copy link

请问 NotImplementedError: WARNING 'YOLO' model does not support '_new' mode for 'None' task yet. 的问题得到解决了吗,我在使用yolov8-rtdetr.yaml训练时也出现了同样的问题,如果有解决办法希望您能够分享,非常感谢!

@glenn-jocher
Copy link
Member

@nzbanana 您好!这个NotImplementedError通常是因为在创建模型时没有正确指定任务类型。请确保在使用yolov8-rtdetr.yaml配置文件时,正确设置了任务参数。如果问题仍然存在,请确保您使用的是最新版本的YOLOv8代码,并且遵循我们的官方文档中的指南。如果还有问题,请在GitHub issues上提供更多详细信息,我们会尽快帮助您解决。谢谢!🙂

@xinwaha
Copy link

xinwaha commented Mar 11, 2024

@nzbanana
Perhaps the incorrect instruction model=YOLO ('ultra tics/cfg/models/rt detr/rtdetr resnet50. yaml ') was used
You should change YOLO to RTDETR
model = RTDETR('ultralytics/cfg/models/rt-detr/rtdetr-l.yaml')

请问 NotImplementedError: WARNING 'YOLO' model does not support '_new' mode for 'None' task yet. 的问题得到解决了吗,我在使用yolov8-rtdetr.yaml训练时也出现了同样的问题,如果有解决办法希望您能够分享,非常感谢!

@nzbanana
Perhaps the incorrect instruction model=YOLO ('ultra tics/cfg/models/rt detr/rtdetr resnet50. yaml ') was used
You should change YOLO to RTDETR
model = RTDETR('ultralytics/cfg/models/rt-detr/rtdetr-l.yaml')

@songyue1207
Copy link

I guess this issue arises because the network cannot determine the type of "task". The main debugging should be done in the ‘’‘guess_model_task’‘’ function in tasks.py. I modified the line ‘’‘if m == ('classify', 'classifier', 'cls', 'fc')’‘’ to ‘’‘if m in ('classify', 'classifier', 'cls', 'fc')’‘’.

@glenn-jocher
Copy link
Member

@songyue1207 Thanks for sharing your insight! 🌟 It indeed looks like the task guessing logic might have been the culprit. Adjusting the condition as you suggested should make it more robust by properly evaluating if m is within the specified tuple. This change should help in resolving ambiguities in task identification. Great catch!

For clarity, here's the modified line in context:

# tasks.py - guess_model_task function
if m in ('classify', 'classifier', 'cls', 'fc'):
  ...

This tweak ensures the function accurately identifies the task based on the model's characteristics. If anyone else encounters similar issues, this might be a good starting point for debugging. Thanks again for pointing this out! 👍

@ratom
Copy link

ratom commented Jun 6, 2024

Is there any solution to train rtdetr

@glenn-jocher
Copy link
Member

@ratom hello! To train the RT-DETR model using the Ultralytics framework, ensure you're using the correct model initialization and training commands. Here’s a quick guide:

  1. Initialize the Model: Make sure to use RTDETR instead of YOLO when loading your model configuration.

    from ultralytics import RTDETR
    model = RTDETR('path/to/rtdetr-config.yaml')
  2. Training the Model: Use the train method with appropriate parameters.

    results = model.train(data='path/to/dataset.yaml', epochs=100, imgsz=640)

Ensure your dataset and configuration files are correctly set up. If you encounter any specific errors during this process, please provide the error messages and details about your setup for more targeted assistance. Happy training! 🚀

@Naruto123882
Copy link

@ratom你好!要使用 Ultralytics 框架训练 RT-DETR 模型,请确保使用正确的模型初始化和训练命令。以下是快速指南:

  1. 初始化模型:确保在加载模型配置时使用RTDETR而不是。YOLO
    from ultralytics import RTDETR
    model = RTDETR('path/to/rtdetr-config.yaml')
  2. 训练模型:使用train具有适当参数的方法。
    results = model.train(data='path/to/dataset.yaml', epochs=100, imgsz=640)

确保数据集和配置文件设置正确。如果您在此过程中遇到任何特定错误,请提供有关您的设置的错误消息和详细信息,以获得更有针对性的帮助。祝您训练愉快!🚀

RTDETR

Hello, may I ask:
I used yolov8 for vehicle inspection and made a series of improvements to the V8.
I've been using the YOLO () format for training. Suppose the result of replacing YOLO with RTDETR is A, and compare it with the previous result of YOLO, is this correct? Do you use influence?

@huangsiconggggg
Copy link

In case someone is till trying to figure out this problem, I'd like to make some supplements.
train with RTDETR, which is mentioned by @Naruto123882
from ultralytics import RTDETR
model = RTDETR('path/to/rtdetr-config.yaml')

If you still want to use YOLO to train, you should define task 👇(python):
model = YOLO("yolov8-rtdetr.yaml", task="cls")
or👇(CLI):
model = YOLO("E:/fourworkplace/ultralytics-main/ultralytics/cfg/models/v8/yolov8-rtdetr.yaml", task="cls")

@winterscoming
Copy link

winterscoming commented Oct 13, 2024

from ultralytics import RTDETR
model = RTDETR('ultralytics/cfg/models/rt-detr/rtdetr-l.yaml')

#===yaml===#
backbone:

[from, repeats, module, args]

  • [-1, 1, HGStem, [32, 48]] # 0-P2/4

  • [-1, 6, HGBlock, [48, 128, 3]] # stage 1

  • [-1, 1, DWConv, [128, 3, 2, 1, False]] # 2-P3/8

  • [-1, 6, HGBlock, [96, 512, 3]] # stage 2

  • [-1, 1, DWConv, [512, 3, 2, 1, False]] # 4-P3/16

  • [-1, 6, HGBlock, [192, 1024, 5, True, False]] # cm, c2, k, light, shortcut

  • [-1, 6, HGBlock, [192, 1024, 5, True, True]]

  • [-1, 6, HGBlock, [192, 1024, 5, True, True]] # stage 3

  • [-1, 1, DWConv, [1024, 3, 2, 1, False]] # 8-P4/32

  • [-1, 6, HGBlock, [384, 2048, 5, True, False]] # stage 4

When I was using this yaml, an error occurred in the third module DWConv while printing network structure information,looking forward to your guidance
TypeError: init() takes from 1 to 2 positional arguments but 7 were given

@glenn-jocher
Copy link
Member

It seems like there's an issue with the DWConv module's initialization parameters. Please check the module's definition to ensure the correct number of arguments is being passed. If the problem persists, reviewing the module's documentation or source code might help clarify the required parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale Stale and schedule for closing soon
Projects
None yet
Development

No branches or pull requests

9 participants