Comments (4)
π Hello @Shybert-AI, thank you for your interest in Ultralytics YOLOv8 π! We recommend a visit to the 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):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
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.
from ultralytics.
Hello! It seems like the model is encountering a "KeyError" which typically suggests that there's a mismatch in the number of classes between the trained model and the class names provided during inference.
Ensure that your class names file (often labeled *.names
or defined in your dataset .yaml
file) correctly lists all 5 classes you trained the model on, and that it's properly linked in your inference script or command line parameters. The error suggests the model is expecting a class index that doesn't exist in the provided class names.
Hereβs a basic checklist:
- Check the
.names
file or similar to ensure all your classes are listed there. - Verify the path to your class names file in the
.yaml
or as a model argument is correct. - Re-run the inference ensuring all files are in the correct locations.
If everything appears correct and the error persists, consider re-exporting or re-saving your model configuration.
Let me know how it goes, or if there's anything else you need help with! π
from ultralytics.
Thank
you very much, it has been resolved. When using the yolo command line, an error will be reported. Replace the command line with the following Python code to perform inferenceγ
yolo detect predict model=./runs/detect/train/weights/best.pt source="00001.jpg"
replace
from ultralytics import YOLO,RTDETR
model = RTDETR("./ultralytics/cfg/models/rt-detr/rtdetr-l.yaml").load('runs/detect/train/weights/last.pt')
results = model(['00001.jpg']) # return a list of Results objects
for result in results:
boxes = result.boxes # Boxes object for bounding box outputs
masks = result.masks # Masks object for segmentation masks outputs
keypoints = result.keypoints # Keypoints object for pose outputs
probs = result.probs # Probs object for classification outputs
obb = result.obb # Oriented boxes object for OBB outputs
result.show() # display to screen
result.save(filename='result.jpg') # save to disk
from ultralytics.
Hello! I'm glad to hear that the issue has been resolved π! The method you used to perform inference through the Python script is indeed a great alternative if you encounter issues with the command line. It also provides more flexibility for post-processing and handling the results. Thanks for sharing your solution; it could be helpful to others facing similar problems. If there's anything more we can assist you with, don't hesitate to ask. Happy detecting! π
from ultralytics.
Related Issues (20)
- How to adapt the v8 model to incorporate the ordinal regression using the CORAL/CORN implementation. HOT 3
- ultralytics version compatibility issue with yolov8n-cls model HOT 3
- Resume training pretrained yolov8 segmentation model. HOT 13
- Error TypeError: new(): invalid data type 'str' for custom trainer HOT 1
- Error TypeError: new(): invalid data type 'str' for custom trainer HOT 2
- Validation result
- How to achieve more mAP50 for disease detection HOT 7
- Can SAHI inference performs real time object detection? HOT 7
- yolov8 : Adding New data class to customized yolov8 model HOT 8
- cuda/IndexKernel.cu:92: index out of bounds TORCH_USE_CUDA_DSA HOT 8
- mask_overlap=False still gives overlapping masks HOT 2
- GPU_mem = 0 Using Apple M2 Chip HOT 7
- YOLOv8 on a one-class detection HOT 4
- The input image size is inconsistent during training and verification HOT 5
- How can I utilize all GPU memory to return the fastest response to all requests? HOT 4
- handling images of different sizes HOT 8
- Anomaly Detection HOT 3
- Segmentation label format not working!!!? HOT 1
- Help Needed with YoloV8 OBB Inference and NCNN Model Integration. HOT 13
- YOLOv8 Parameter Depth_multiple, Width_multiple, and max_channel HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.