Comments (12)
👋 Hello @Damiano004, 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.
Hi there,
It looks like the system is not finding your data.yaml
file at the specified path, or the file might be empty. Please ensure the data.yaml
file exists at the specified location and is correctly formatted with the necessary dataset paths and other required metadata.
Here's a quick checklist:
- Make sure the file
data.yaml
is not empty and exists atC:/Users/damiano.purin/Python/datasets/CarDetection2/prova/data.yaml
. - Confirm that the file contains valid YAML content describing your dataset. Here is an example format:
train: path/to/train/images
val: path/to/validation/images
nc: number_of_classes
names: ['class1', 'class2', ...]
Once these checks are done, your script should locate the dataset without attempting to download it. If issues persist, please double-check paths and ensure they are accessible to your Python script.
Thanks for reaching out, let me know how it goes! 🚀
from ultralytics.
Hi there,
It looks like the system is not finding your
data.yaml
file at the specified path, or the file might be empty. Please ensure thedata.yaml
file exists at the specified location and is correctly formatted with the necessary dataset paths and other required metadata.Here's a quick checklist:
- Make sure the file
data.yaml
is not empty and exists atC:/Users/damiano.purin/Python/datasets/CarDetection2/prova/data.yaml
.- Confirm that the file contains valid YAML content describing your dataset. Here is an example format:
train: path/to/train/images val: path/to/validation/images nc: number_of_classes names: ['class1', 'class2', ...]Once these checks are done, your script should locate the dataset without attempting to download it. If issues persist, please double-check paths and ensure they are accessible to your Python script.
Thanks for reaching out, let me know how it goes! 🚀
Hi, thanks for the reply.
I have checked my paths, by copying the paths in the code and pasting them in the file explorer, and they all have a destination, they all exsist.
By the way, here's the content of data.yaml
PS: i also checked these paths, and they all exsist.
thanks
from ultralytics.
Hi again, i may am just dumb. I tried switching model, from "yolov8n-cls" to just "yolov8n", and i think it worked? Or at least i think.
I read the whole output in the terminal and it doesen't seem there are any errors or whatever.
I wanted to fine-tune the yolov8 model with a custom dataset that i prepared, this code is doing what i want him to do right?
Also, now that i trained for 1 epoch, yeah i know that it isn't enough, it was just for testing, where are the file i need to make the model work, i think i just need the configuration file and the wheight file, but i could be wrong.
Thank you!
from ultralytics.
Hey!
Great to hear switching to "yolov8n" seemed to work! If your goal is fine-tuning with a custom dataset, the code you've shared does indeed initiate training with YOLOv8. You're on the right track! 🚀
After training, the model weights are typically saved as .pt
files in a run-specific directory under runs/train/
. You'll find the latest weights in last.pt
and the best performing ones (if saving is enabled during validation) in best.pt
. These .pt
files contain all the configuration and weights needed for deploying or further training your model.
For deploying or further fine-tuning, the .pt
file is what you primarily need. Keep it up, and if you have more questions or need further assistance, feel free to reach out!
Happy training!
from ultralytics.
Hi! Thanks again for answering.
So, until now i was using a premade, pretrained yolov4 model for my application, and to deploy that i was using cv2.
I've done a bit of research and, from what i understood, cv2 ain't compatible with pt files.
I found some workarounds but i was wandering if i should change the approach or if it was better to stick to cv2.
If that helps here's the code of "vehicle_detector.py":
and here's my "application.py":
Thanks again
from ultralytics.
@Damiano004 hey there!
You're right, cv2
doesn't natively support .pt
files since these are specific to PyTorch models. However, with your YOLOv8 model, you can still utilize cv2
for handling image pre-processing or displaying results, but you'd use PyTorch for loading the model and running the inference.
Here's a quick example on integrating cv2
with PyTorch for your vehicle detection:
import cv2
from ultralytics import YOLO
# Load your trained model
model = YOLO('path_to_your_trained_model.pt')
# Capture video
cap = cv2.VideoCapture('path_to_your_video.mp4')
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
# Run model
results = model(frame)
# Draw bounding boxes and labels on the frame
frame = results.render()[0] # Updated frame with drawings
cv2.imshow('Vehicle Detection', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release everything when job is finished
cap.release()
cv2.destroyAllWindows()
This integrates PyTorch's model handling with cv2
's video capabilities efficiently. If you're looking into deploying YOLOv8 models, PyTorch and YOLO's native functionality will be robust and well-supported.
Let me know if you need further assistance! 🚀
from ultralytics.
@Damiano004 hey there!
You're right,
cv2
doesn't natively support.pt
files since these are specific to PyTorch models. However, with your YOLOv8 model, you can still utilizecv2
for handling image pre-processing or displaying results, but you'd use PyTorch for loading the model and running the inference.Here's a quick example on integrating
cv2
with PyTorch for your vehicle detection:import cv2 from ultralytics import YOLO # Load your trained model model = YOLO('path_to_your_trained_model.pt') # Capture video cap = cv2.VideoCapture('path_to_your_video.mp4') while cap.isOpened(): ret, frame = cap.read() if not ret: break # Run model results = model(frame) # Draw bounding boxes and labels on the frame frame = results.render()[0] # Updated frame with drawings cv2.imshow('Vehicle Detection', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break # Release everything when job is finished cap.release() cv2.destroyAllWindows()This integrates PyTorch's model handling with
cv2
's video capabilities efficiently. If you're looking into deploying YOLOv8 models, PyTorch and YOLO's native functionality will be robust and well-supported.Let me know if you need further assistance! 🚀
I've already tried to come to a solution on my own and i figured out a way, but thanks for the help, actually i'm seeing some stuff that could help my code being more clean.
Although i'm heaving some issues back on the training script.
I don't know why, I think that my script is scanning the training images, scanning the validation images, but then using the val images for both the training and the validation, or at least that's what i think it's happening.
Here's the image of the terminal:
Here's the .yaml file:
I've changed the absolute paths to relative ones, bcs absolute paths are cringe, but i actually don't remember if before worked as intended or not.
Thanks for the help, you are divine!
from ultralytics.
Hey @Damiano004,
I'm glad to hear that the previous suggestions were somewhat helpful and that you've made progress on your own as well! 🌟 As for the issue you're encountering in the training script, it's indeed unusual for validation images to be used for both training and validation unless explicitly specified.
From your description, it sounds like there might be a mix-up in how your .yaml
file is structured or interpreted by the script. Double-checking the paths and structure of your .yaml
file can help clarify things:
- Confirm that the
train
andval
paths in your.yaml
file correctly point to separate directories. - Ensure there's no overlap in the images between these directories.
If everything seems in order but the problem persists, try returning to absolute paths temporarily to verify functionality. If switching back to absolute paths solves the issue, there might be a problem with how relative paths are being resolved in your environment.
And finally, if you want to post or email the contents or screenshot of your .yaml
file (while ensuring it doesn't include sensitive information), I could take a closer look.
Keep me posted, and we'll get to the bottom of this! 😊
from ultralytics.
Hi @glenn-jocher,
So i tried putting absolute paths in the .yaml file and did not work, it did the same thing as before.
If you want to try fix it i'll send you the project folder (without the images folders so to make it more light):
project.zip
Meanwhile i'll double check everything that could make it go wrong.
I'll keep you updated in case i find something.
Thank you so much for the help.
from ultralytics.
Hey @glenn-jocher,
I found something strange.
You see, i tried running the program with 1 image in the "training folder", it then scanned 1 image as it should be, and when it started the training procedure it instantly finished that, as if that was 1 image in the training folder, however it still says that he processed 71 images.
Here's a video i made to show you (sorry for that text in the bottom right):
https://github.com/ultralytics/ultralytics/assets/156813064/6f787c73-0f9a-4f30-bd44-1a8777ac3491
It takes way more time to process when i put in the folder all the 500 or something photos. I don't understand if it's a bug of some type or if i'm reading that wrong.
I looks like it's working just fine tho, it's just that thing that is misleading.
from ultralytics.
Hey there!
Thanks for sharing the video and details. It sounds like there might be a discrepancy in how the dataset is being loaded or reported during the training process. The count of processed images might be reflecting the total number of data augmentations or batch iterations, rather than the unique images.
To clarify, could you check the batch size and the number of workers in your training configuration? Sometimes, these settings can affect how data is loaded and processed, which might explain the numbers you're seeing.
If everything seems correct and you're still noticing this issue, it might be worth looking into the data loader part of the code to ensure it's iterating over the dataset as expected.
Keep me posted on what you find! 🚀
from ultralytics.
Related Issues (20)
- Detection for Small objects HOT 4
- Illegal instruction: 4 with yolov8 pose task testing HOT 6
- coco format HOT 10
- training yolov8 on a different data set than I had previously trained it on became extremely slow HOT 2
- code issue HOT 2
- guides/object-counting/ HOT 2
- how to add Transformer block to YOLOv8-seg architecture? HOT 3
- Error Dimension mismatch while using model.track (object-counting) on Coral Edge TPU HOT 7
- Triton remote model not working with https HOT 1
- Detection model training with segmentation annotation HOT 3
- YOLOv10 branch doesn't exist in newer ultralytics versions HOT 4
- Is it possible to use the predict result .txt as the training label .txt? HOT 2
- Problem converting tensorrt engine after converting yolov8-worldv2 to onnx HOT 2
- Does the Augmentation Settings process corrects labels? HOT 2
- Test Intel Gaudi2 integration
- Scalar Plot for Fitness parameter for YOLO V8 HOT 3
- c++ yolov8 inference onnx error occurred HOT 4
- NCHW vs NHWC HOT 4
- How many layers is the backbone in the segmentation model of YoloV8? HOT 2
- Can't export model with 8.2.24 HOT 5
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.