Skip to content

Latest commit

 

History

History

YOLOv8

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

YOLOv8 Object Detection

A simple showcase of how we can train a YOLOv8 for Object Detection, it's a straightforward library.

Pred 1 Pred 2
First prediction Second prediction

Dataset

I go to https://universe.roboflow.com/roboflow-100/road-signs-6ih4y and download the dataset choosing the YOLOv8 text annotation as shown below:

Prompt roboflow download road signs dataset

Dependencies

Create a virtual environment, I'm using virtualenv. Install ultralytics using pip. Note: this will install the PyTorch version recommended too.

$ python -m venv .venv
$ source .venv/bin/activate # Unix
$ pip install ultralytics jupyter Pillow matplotlib

Training and Validation

You can find all the training, validation, and testing tasks on the notebook: TrainingYoloV8.ipynb

Metrics Results

PR Curve

Confusion Matrix

Testing

On the same notebook TrainingYoloV8.ipynb you can see at the end the predictions using the test dataset. The snippet of the code:

model = YOLO("run/train2/weights/best.pt")
plt.figure(figsize=(14, 80))
for i, img_file in enumerate(glob(os.path.join(TEST_IMAGES_DATASET_PATH, "*.jpg"))[:60], start=1):
    plt.subplot(20, 3, i)
    results = model.predict(source=img_file, 
                            save=True, 
                            project=os.path.join(os.getcwd(), "run", "predict"), 
                            verbose=False)

    # Obtain the path of the file saved
    filepath = os.path.join(results[0].save_dir, os.path.basename(results[0].path))
    im_res = Image.open(filepath)
    plt.imshow(im_res)