YOLO-NAS
YOLO-NAS의 최초 개발사인 Deci는 NVIDIA에 인수되었으며, Deci는 더 이상 이 모델을 적극적으로 유지 관리하지 않습니다. Ultralytics는 해당 모델의 사용을 계속 지원하지만, 원래 팀에서 추가 업데이트를 제공할 예정은 없습니다.
개요#
Deci AI가 개발한 YOLO-NAS는 신경망 아키텍처 탐색으로 생성된 객체 검출 모델이며, 이전 YOLO 모델의 한계를 해결하도록 설계되었습니다. 양자화 지원과 정확도-지연 시간 간 트레이드오프를 개선합니다.
YOLO-NAS 개요. YOLO-NAS는 양자화 후에도 정확도를 유지하기 위해 양자화 인식 블록과 선택적 양자화를 사용합니다. INT8 양자화 버전으로 변환해도 모델의 정확도 저하가 적어 이전 YOLO 모델보다 개선된 성능을 보입니다.
주요 기능#
- 양자화 친화적 기본 블록: YOLO-NAS는 양자화에 적합한 새로운 기본 블록을 도입하여 이전 YOLO 모델의 주요 한계 중 하나를 해결합니다.
- 고급 학습 및 양자화: YOLO-NAS는 성능 향상을 위해 고급 학습 기법과 학습 후 양자화를 사용합니다.
- AutoNAC 최적화 및 사전 학습: YOLO-NAS는 AutoNAC 최적화를 사용하며 COCO, Objects365, Roboflow 100 등의 데이터셋으로 사전 학습됩니다. 이러한 사전 학습 덕분에 프로덕션 환경의 다운스트림 객체 검출 작업에 적합합니다.
사전 학습 모델#
Ultralytics는 속도와 정확도의 균형이 서로 다른 세 가지 크기의 사전 학습된 YOLO-NAS 모델을 제공합니다:
| 모델 | mAP50-95 | 지연 시간 (ms) |
|---|---|---|
| YOLO-NAS S | 47.5 | 3.21 |
| YOLO-NAS M | 51.55 | 5.85 |
| YOLO-NAS L | 52.22 | 7.87 |
| YOLO-NAS S INT-8 | 47.03 | 2.36 |
| YOLO-NAS M INT-8 | 51.0 | 3.78 |
| YOLO-NAS L INT-8 | 52.1 | 4.78 |
각 모델 변형은 평균 정밀도(mAP)와 지연 시간 간의 균형을 제공하도록 설계되어, 성능과 속도 측면에서 객체 탐지 작업을 최적화하는 데 도움이 됩니다.
사용 예시#
ultralytics Python 패키지는 YOLO-NAS 모델을 실행하기 위한 Python API와 CLI를 제공합니다.
YOLO-NAS 모델에는 super-gradients 패키지가 필요하며, 이 패키지를 사용하려면 Python 3.10 환경이 필요합니다.
pip install ultralytics super-gradients "setuptools<81"다음 예제에서는 추론과 검증에 ultralytics 패키지를 사용하여 YOLO-NAS 모델을 사용하는 방법을 보여줍니다:
추론 및 검증 예제#
이 예시에서는 COCO8 데이터셋으로 YOLO-NAS-s를 검증합니다.
이 예시에서는 YOLO-NAS의 간단한 추론 및 검증 코드를 제공합니다. YOLO-NAS는 내보내기도 지원하지만, ultralytics 패키지는 YOLO-NAS 학습을 지원하지 않습니다.
PyTorch 사전 학습 *.pt 모델 파일을 NAS() 클래스에 전달하여 Python에서 모델 인스턴스를 생성할 수 있습니다:
from ultralytics import NAS
# COCO로 사전 학습된 YOLO-NAS-s 모델 로드
model = NAS("yolo_nas_s.pt")
# 모델 정보 표시(선택 사항)
model.info()
# COCO8 예제 데이터셋에서 모델 검증
results = model.val(data="coco8.yaml")
# 'bus.jpg' 이미지에서 YOLO-NAS-s 모델로 추론 실행
results = model("path/to/bus.jpg")지원 작업 및 모드#
YOLO-NAS는 Small(s), Medium(m), Large(l)의 세 가지 변형으로 제공됩니다. 각 변형은 서로 다른 연산 및 성능 요구 사항에 맞게 설계되었습니다:
- YOLO-NAS-s: 계산 리소스가 제한적이지만 효율성이 중요한 환경에 최적화되어 있습니다.
- YOLO-NAS-m: 정확도가 더 높은 범용 객체 검출에 적합한 균형 잡힌 성능을 제공합니다.
- YOLO-NAS-l: 계산 리소스가 큰 제약이 되지 않는 환경에서 최고 수준의 정확도가 필요한 시나리오에 맞춰 설계되었습니다.
아래에서는 각 모델의 사전 학습 가중치 링크, 지원 작업, 다양한 작동 모드와의 호환성을 자세히 살펴봅니다.
| 모델 유형 | 사전 학습 가중치 | 지원 작업 | 학습 | 검증 | 추론 | 내보내기 |
|---|---|---|---|---|---|---|
| YOLO-NAS-s | yolo_nas_s.pt | 객체 탐지 | ❌ | ✅ | ✅ | ✅ |
| YOLO-NAS-m | yolo_nas_m.pt | 객체 탐지 | ❌ | ✅ | ✅ | ✅ |
| YOLO-NAS-l | yolo_nas_l.pt | 객체 탐지 | ❌ | ✅ | ✅ | ✅ |
인용 및 감사의 글#
연구 또는 개발 작업에서 YOLO-NAS를 사용하신다면 SuperGradients를 인용해 주세요:
@misc{supergradients,
doi = {10.5281/ZENODO.7789328},
url = {https://zenodo.org/records/7789328},
author = {Aharon, Shay and {Louis-Dupont} and {Ofri Masad} and Yurkova, Kate and {Lotem Fridman} and {Lkdci} and Khvedchenya, Eugene and Rubin, Ran and Bagrov, Natan and Tymchenko, Borys and Keren, Tomer and Zhilko, Alexander and {Eran-Deci}},
title = {Super-Gradients},
publisher = {GitHub},
journal = {GitHub repository},
year = {2021},
}컴퓨터 비전 커뮤니티를 위해 이 유용한 리소스를 만들고 유지 관리해 주신 Deci AI의 SuperGradients 팀에 감사드립니다.
자주 묻는 질문#
Deci AI가 개발한 YOLO-NAS는 신경망 아키텍처 탐색(NAS)을 활용해 설계된 객체 탐지 모델입니다. 양자화에 적합한 기본 블록과 고급 학습 기법 같은 기능을 도입하여 이전 YOLO 모델의 한계를 해결하고, 특히 연산 리소스가 제한된 환경에서 성능을 향상합니다. 또한 YOLO-NAS는 양자화를 지원하며 INT8 버전으로 변환한 후에도 높은 정확도를 유지해 프로덕션 환경에 더욱 적합합니다.
ultralytics패키지를 사용해 YOLO-NAS 모델을 Python 애플리케이션에 통합할 수 있습니다. 사전 학습된 YOLO-NAS 모델을 로드하고 추론을 수행하는 간단한 예시는 다음과 같습니다:from ultralytics import NAS # COCO로 사전 학습된 YOLO-NAS-s 모델 로드 model = NAS("yolo_nas_s.pt") # COCO8 예제 데이터셋에서 모델 검증 results = model.val(data="coco8.yaml") # 'bus.jpg' 이미지에서 YOLO-NAS-s 모델로 추론 실행 results = model("path/to/bus.jpg")자세한 내용은 추론 및 검증 예제를 참조하세요.
YOLO-NAS는 양자화된 객체 검출에 적합한 다음과 같은 주요 기능을 제공합니다:
- 양자화 친화적 기본 블록: 양자화 후에도 정확도를 유지하는 향상된 아키텍처입니다.
- 고급 학습 및 양자화: 고급 학습 기법과 학습 후 양자화 기술을 사용합니다.
- AutoNAC 최적화 및 사전 학습: AutoNAC 최적화를 사용하며 COCO, Objects365 및 Roboflow 100과 같은 데이터셋으로 사전 학습됩니다.
이러한 기능은 높은 정확도와 효율적인 성능을 제공하고 프로덕션 환경에 배포하기에 적합하도록 합니다. 자세한 내용은 주요 기능 섹션을 참조하세요.
YOLO-NAS 모델은 검증, 추론, 내보내기 모드에서 객체 탐지를 지원합니다. 학습은 지원하지 않습니다. 지원 모델에는 YOLO-NAS-s, YOLO-NAS-m, YOLO-NAS-l이 포함되며, 각 모델은 서로 다른 연산 용량과 성능 요구에 맞게 설계되었습니다.
예. Ultralytics는 바로 사용할 수 있는 사전 학습된 YOLO-NAS 모델을 제공합니다. 이 모델은 COCO와 같은 데이터셋으로 사전 학습됩니다. 지원 작업 및 모드 섹션의 링크를 사용해 모델을 다운로드할 수 있습니다. 예시는 다음과 같습니다:
댓글21
질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.
riobastian09
Hi. i want to know is there any pre-configured of YOLO-NAS model? i want to use this to my experiment using the custom architecture YOLO-NAS model. Thank you!
Glenn JocherUltralytics@riobastian09 thank you for your question! Yes, pre-configured YOLO-NAS models, such as YOLO-NAS-s, YOLO-NAS-m, and YOLO-NAS-l, are available and optimized for inference, validation, and export. You can access these pre-trained models and easily integrate them into your experiments using the Ultralytics Python package. Unfortunately, custom architecture modifications or training directly with YOLO-NAS are not supported. For more, refer to the YOLO-NAS documentation: https://docs.ultralytics.com/models/yolo-nas/
User您好,我使用如下脚本将torch模型转成onnx模型时,出现如下错误: raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'YoloNAS_S' object has no attribute 'args'我该如何解决?
Userfrom ultralytics import NAS model = NAS('yolo_nas_s') model.export( imgsz = [480,640], format = "onnx", simplify = True, opset = 17 )
Glenn JocherUltralytics@Stephen-Hao it seems like the error you're encountering is due to the 'args' attribute not being present in the 'YoloNAS_S' object. This might be related to the specific version of the model or the Ultralytics package you are using. Please ensure you have the latest version of the Ultralytics package installed. If the issue persists, consider checking the model's documentation or reaching out to the community for further assistance.
NoviceAlchemist
我训练使用的代码是:import torch import warnings from ultralytics import YOLO
忽略与“deterministic”和“non-deterministic”相关的所有警告
warnings.filterwarnings("ignore", category=UserWarning, message=".deterministic.")
if name == 'main': # 关闭PyTorch的确定性算法 torch.use_deterministic_algorithms(False)
# 初始化YOLO模型 # model_path = r'D:\ultralytics-main\ultralytics\cfg\models\v8\yolov8_attiton.yaml' model_path = r'D:\ultralytics-main\model train\model\yolo_nas_s.pt' model = YOLO(model_path) # 设置正确的数据集路径 data_path = r"C:\Users\13579\Downloads\etiketlenmis_3.v6i.yolov8\data.yaml" # 训练模型配置信息 model.train(data=data_path, imgsz=640, batch=32, epochs=200, name='NAS_S', ) # 设置验证集验证效果 # model.val()但是会出现D:\Anaconda3\envs\yolov8\python.exe "D:\ultralytics-main\model train\My train\yolo nas.py" The console stream is logged into C:\Users\13579\sg_logs\console.log [2024-09-06 10:23:49] INFO - crash_tips_setup.py - Crash tips is enabled. You can set your environment variable to CRASH_HANDLER=FALSE to disable it [2024-09-06 10:23:49,572] torch.distributed.elastic.multiprocessing.redirects: [WARNING] NOTE: Redirects are currently not supported in Windows or MacOs. [WARNING]No module named 'pycocotools' [2024-09-06 10:23:51] WARNING - env_sanity_check.py - Failed to verify operating system: Deci officially supports only Linux kernels. Some features may not work as expected. WARNING ⚠️ The file 'D:\ultralytics-main\model train\model\yolo_nas_s.pt' appears to be improperly saved or formatted. For optimal results, use model.save('filename.pt') to correctly save YOLO models. Traceback (most recent call last): File "D:\ultralytics-main\model train\My train\yolo nas.py", line 15, in model = YOLO(model_path) File "D:\ultralytics-main\ultralytics\models\yolo\model.py", line 23, in init super().init(model=model, task=task, verbose=verbose) File "D:\ultralytics-main\ultralytics\engine\model.py", line 149, in init self._load(model, task=task) File "D:\ultralytics-main\ultralytics\engine\model.py", line 230, in _load self.model, self.ckpt = attempt_load_one_weight(weights) File "D:\ultralytics-main\ultralytics\nn\tasks.py", line 855, in attempt_load_one_weight ckpt, weight = torch_safe_load(weight) # load ckpt File "D:\ultralytics-main\ultralytics\nn\tasks.py", line 809, in torch_safe_load ckpt = {"model": ckpt.model} File "D:\Anaconda3\envs\yolov8\lib\site-packages\torch\nn\modules\module.py", line 1695, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'YoloNAS_S' object has no attribute 'model'
进程已结束,退出代码为 1
这个怎么解决呀
Glenn JocherUltralytics(수정됨)@NoviceAlchemist YOLO-NAS models in Ultralytics are pretrained and support only validation, inference and export, not training (see the Training column in the YOLO-NAS docs), so
model.train()isn't available foryolo_nas_s.pt. To train on your own dataset, use a model with training support such as YOLO26 (e.g.yolo26s.pt). If you hit model-loading errors, verify thatpycocotoolsis installed and try the latest version of the Ultralytics package.
dota2015
from ultralytics import NAS import cv2
Load a COCO-pretrained YOLO-NAS-s model
model = NAS('yolo_nas_s.pt')
Display model information (optional)
model.info() results = model.predict('000000000009.jpg')
run reslult:
C:\Users\makef.conda\envs\yolov8\python.exe -X pycache_prefix=C:\Users\makef\AppData\Local\JetBrains\PyCharm2023.3\cpython-cache "C:/Program Files/JetBrains/PyCharm 2023.3.4/plugins/python/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 62105 --file D:\02Code\code\yolov8\v8_2\yolo_nas.py Connected to pydev debugger (build 233.15026.15) The console stream is logged into C:\Users\makef\sg_logs\console.log [2024-04-28 16:29:38] INFO - crash_tips_setup.py - Crash tips is enabled. You can set your environment variable to CRASH_HANDLER=FALSE to disable it [2024-04-28 16:29:39] WARNING - redirects.py - NOTE: Redirects are currently not supported in Windows or MacOs. [WARNING]No module named 'pycocotools' [2024-04-28 16:29:45] WARNING - env_sanity_check.py - Failed to verify operating system: Deci officially supports only Linux kernels. Some features may not work as expected. Model summary: 685 layers, 19053888 parameters, 19053888 gradients
Traceback (most recent call last): File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\torch\autograd\grad_mode.py", line 43, in generator_context response = gen.send(None) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\predictor.py", line 228, in stream_inference self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz)) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\nn\autobackend.py", line 624, in warmup self.forward(im) # warmup File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\nn\autobackend.py", line 450, in forward y = self.model(im, augment=augment, visualize=visualize, embed=embed) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'augment' python-BaseException
Process finished with exit code 1
Paula DerrengerUltralyticsHey there! 👋 It looks like you're encountering a
TypeErrorrelated to theaugmentkeyword argument when running inference with the YOLO-NAS model. The error suggests that theforward()method in the model doesn't recognize theaugmentargument. This could be due to an oversight in the code or an issue with the model's compatibility with the Ultralytics framework.Let's try running the model without any additional arguments that aren't expected. Here's how you can do it:
from ultralytics import NAS # Load a COCO-pretrained YOLO-NAS-s model model = NAS('yolo_nas_s.pt') # Run inference with the YOLO-NAS-s model on the 'bus.jpg' image results = model('path/to/bus.jpg')This simplifies the call to the model's inference method by removing the
augmentargument, which seems to be causing the issue.If you continue to face problems or if the issue is due to something else, it might be a good idea to check the Ultralytics documentation for YOLO-NAS compatibility or raise an issue on the GitHub repository for more specific help! Hope this sorts it out for you! 😊
dota2015(수정됨)
Hey there! So, I've decked out my project with all the latest packages, but guess what? The issue is still lurking like it's on a vacation!
Here's the riveting tale of the pip upgrade:
Downloading ultralytics-8.2.4-py3-none-any.whl (752 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 752.1/752.1 kB 28.1 kB/s eta 0:00:00 Installing collected packages: ultralytics Attempting uninstall: ultralytics Found existing installation: ultralytics 8.2.1 Uninstalling ultralytics-8.2.1: Successfully uninstalled ultralytics-8.2.1 Successfully installed ultralytics-8.2.4
Behold, the saga of the runtime logs unfolds below:
C:\Users\makef.conda\envs\yolov8\python.exe D:\02Code\code\yolov8\v8_2\yolo_nas.py The console stream is logged into C:\Users\makef\sg_logs\console.log [2024-04-29 10:42:17] INFO - crash_tips_setup.py - Crash tips is enabled. You can set your environment variable to CRASH_HANDLER=FALSE to disable it [2024-04-29 10:42:18] WARNING - redirects.py - NOTE: Redirects are currently not supported in Windows or MacOs. [WARNING]No module named 'pycocotools' [2024-04-29 10:42:21] WARNING - env_sanity_check.py - Failed to verify operating system: Deci officially supports only Linux kernels. Some features may not work as expected. Model summary: 685 layers, 19053888 parameters, 19053888 gradients
Behold, the saga of the runtime logs unfolds below: Traceback (most recent call last): File "D:\02Code\code\yolov8\v8_2\yolo_nas.py", line 10, in results = model.predict('000000000009.jpg') File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\model.py", line 452, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\predictor.py", line 168, in call return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\torch\autograd\grad_mode.py", line 43, in generator_context response = gen.send(None) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\predictor.py", line 228, in stream_inference self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz)) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\nn\autobackend.py", line 627, in warmup self.forward(im) # warmup File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\nn\autobackend.py", line 453, in forward y = self.model(im, augment=augment, visualize=visualize, embed=embed) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'augment'
Process finished with exit code 1
Paula DerrengerUltralytics(수정됨)Hey there! 😄 It looks like you're having a bit of a rough ride with the
augmentargument not being recognized during prediction. No worries, let's tidy this up!The error message you're seeing is due to the
augmentargument being passed where it was not expected. It's a simple fix; you just need to ensure you're using the prediction functionality without this argument, like so:from ultralytics import NAS # Load the COCO-pretrained YOLO-NAS-s model model = NAS('yolo_nas_s.pt') # Run inference on an image results = model('path/to/000000000009.jpg') # To visualize the results, you can do: results[0].show()This should run smoothly and get your project back on track! If issues persist or you have further questions, feel free to reach out. And remember, for the latest and greatest on usage, our docs page is always there to help you out. Happy coding! 🚀
dota2015
I used your code, but the problem still persists, like a mischievous little gremlin playing hide and seek.
Paula DerrengerUltralytics(수정됨)Hey there! 🌟 It looks like that mischievous gremlin of an issue is quite stubborn. Not to worry, let's tackle it together.
Based on your feedback and the details from the YOLO-NAS docs, it seems like you're on the right track. However, if you're still encountering issues with predictions or validation, it's possible there might be a version mismatch or a missing dependency, especially
pycocotoolswhich is crucial for dataset operations and was flagged in your logs.Firstly, please ensure you've installed
pycocotoolsby running:pip install pycocotools-windowsIf you're not on Windows, just
pycocotoolsshould work.Moreover, the error regarding the
augmentargument not being expected might suggest an incompatibility issue or an outdated piece of code. Let's try simplifying the inference code snippet to not use this argument, as shown in the Ultralytics YOLO-NAS docs:from ultralytics import NAS # Load the COCO-pretrained YOLO-NAS-s model model = NAS('yolo_nas_s.pt') # Run inference with the YOLO-NAS-s model on a local image file results = model('path/to/bus.jpg') # Visualize the results results[0].show()This code directly uses the model without additional settings that may not be supported, like
augment.If the problem continues, it could be helpful to check for updates to the Ultralytics package or consider reaching out on the GitHub issues page for more targeted support. Sometimes, issues like these have been encountered and solved by others in the community!
Don't let those gremlins get you down; you're closer to a solution than you think! 🚀
dota2015
C:\Users\makef.conda\envs\yolov8\python.exe D:\02Code\code\yolov8\v8_2\yolo_nas.py The console stream is logged into C:\Users\makef\sg_logs\console.log [2024-04-28 16:27:19] INFO - crash_tips_setup.py - Crash tips is enabled. You can set your environment variable to CRASH_HANDLER=FALSE to disable it [2024-04-28 16:27:20] WARNING - redirects.py - NOTE: Redirects are currently not supported in Windows or MacOs. [WARNING]No module named 'pycocotools' [2024-04-28 16:27:23] WARNING - env_sanity_check.py - Failed to verify operating system: Deci officially supports only Linux kernels. Some features may not work as expected. Model summary: 685 layers, 19053888 parameters, 19053888 gradients Traceback (most recent call last): File "D:\02Code\code\yolov8\v8_2\yolo_nas.py", line 10, in results = model.predict('000000000009.jpg') File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\model.py", line 452, in predict return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\predictor.py", line 168, in call return list(self.stream_inference(source, model, *args, **kwargs)) # merge list of Result into one File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\torch\autograd\grad_mode.py", line 43, in generator_context response = gen.send(None) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\engine\predictor.py", line 228, in stream_inference self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz)) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\nn\autobackend.py", line 624, in warmup self.forward(im) # warmup File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\ultralytics\nn\autobackend.py", line 450, in forward y = self.model(im, augment=augment, visualize=visualize, embed=embed) File "C:\Users\makef.conda\envs\yolov8\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) TypeError: forward() got an unexpected keyword argument 'augment'
Process finished with exit code 1
dota2015
from ultralytics import NAS import cv2
Load a COCO-pretrained YOLO-NAS-s model
model = NAS('yolo_nas_s.pt')
Display model information (optional)
model.info()
results = model.predict('000000000009.jpg')
Paula DerrengerUltralyticsHey there! 👋 It looks like you're trying to run predictions with the YOLO-NAS model and encountered an issue regarding the
augmentargument in theforward()method. This error typically occurs if there's a version mismatch or if the model and method usage doesn't align with the expected input parameters.Based on your usage:
from ultralytics import NAS import cv2 # Load a COCO-pretrained YOLO-NAS-s model model = NAS('yolo_nas_s.pt') # Display model information (optional) model.info() results = model.predict('000000000009.jpg')It seems correct on the surface, suggesting it might be related to the version of Ultralytics library you're using or specific to the model's implementation.
Here are a couple of steps you might want to try:
- Ensure you have the latest version of the Ultralytics package by running:
pip install --upgrade ultralytics - Check if the YOLO-NAS model you are using is compatible with the predict function in terms of its expected arguments. You can refer to the official Ultralytics documentation for the YOLO-NAS model and verify the correct method usage.
If you're still facing issues, feel free to share more details, such as the specific error messages and your environment setup. Hopefully, this helps you move forward! 🚀
- Ensure you have the latest version of the Ultralytics package by running:
Pragyy-G
How to train out this Yolo-nas model? like fine tune it on custom dataset?
Glenn JocherUltralytics(수정됨)@Pragyy-G hey there! 🙌 YOLO-NAS in Ultralytics is limited to pretrained weights for inference, validation and export; training and fine-tuning aren't supported (see the Training column in the YOLO-NAS docs), and there is no
Datasetclass to import.To train on a custom dataset, use a model with full training support such as YOLO26:
from ultralytics import YOLO model = YOLO("yolo26n.pt") model.train(data="path/to/data.yaml", epochs=100, imgsz=640)Your dataset should follow the expected format, with a YAML file defining the train/val paths and classes.
Tottowich
@Pragyy-G Any results on this?
ashish-reddy26
Hi Glenn,
I tried training with the provided information, but I am getting the error that says 'Dataset' cannot be imported from ultralytics. Is Ultralytics not providing the resources to Dataset?
Can you clarify this and also please provide your inputs for training yolo-nas for object detection tasks (I am using yolov8 & yolov9, but I also want to try with yolo-nas as well).
Thank you, Ashish
Glenn JocherUltralytics(수정됨)Hi Ashish,
Datasetisn't a directly importable class from theultralyticspackage. For custom training datasets, you structure your data in the expected format and use a YAML file to define paths and classes.YOLO-NAS in Ultralytics supports inference, validation and export only, not training, so to train on a custom dataset use a model like YOLO26. To validate YOLO-NAS:
from ultralytics import NAS # Load the model model = NAS("yolo_nas_s.pt") # Validate the model results = model.val(data="path/to/your/data.yaml")Please ensure your dataset follows the structure expected by the Ultralytics framework and that the YAML file correctly points to your train and validation images and labels.