Coder Social home page Coder Social logo

elahehgolrokh / car-plate-detection-yolov8 Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 2.62 MB

This tutorial will take you from installation, to training YOLOv8 object detection model with a custom dataset, then exporting it for inference.

Python 100.00%

car-plate-detection-yolov8's Introduction

Car Plate Detection using YOLOv8 ๐Ÿš€

predictions Welcome to the car plate detection project using YOLOv8! This repository provides a step-by-step guide to preparing data, training an object detection model with YOLOv8, and running inference with the trained model. video_predictions

Overview

The basic usage is based on the YOLOv8 tutorial, customized for the current dataset to guide you through preparing data and training a model. This tutorial will cover everything from installation to training the YOLOv8 object detection model with a custom dataset and then exporting it for inference.

You can find the dataset used in this project here.

Also here is the kaggle notebook of this project.

Installation

This package is tested on Ubuntu 20.04 with Python 3.9.12. First, create your virtual environment:

python -m venv venv
source venv/bin/activate

Next, install all dependencies:

pip install -r requirements.txt

Data Preparation

To use YOLOv8 for your object detection task, structure your data as follows:

  1. In the root directory of your dataset, create two folders named images and labels. For this tutorial, we consider data/ in the root of our project as the dataset root.
  2. Images can be in jpg or png formats.
  3. Create a config file in yaml format specifying the paths to the root and images directories.
  4. Separating train, validation, and test partitions is optional. If you do this, create subdirectories within both images and labels folders. Specify these paths in the config file.
  5. Labels must be in txt format. For each bounding box in an image, include a row in the corresponding label file with the following structure (no commas): class_label bbx_x_center bbx_y_center bbx_width bbx_height.

The data directory should be structured like this:

data
โ”œโ”€โ”€ images
โ”‚   โ”œโ”€โ”€ test
โ”‚   โ”‚   โ”œโ”€โ”€ Cars27.png
โ”‚   โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ train
โ”‚   โ”‚   โ”œโ”€โ”€ Cars0.png
โ”‚   โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ””โ”€โ”€ validation
โ”‚       โ”œโ”€โ”€ Cars10.png
โ”‚       โ”œโ”€โ”€ ...
โ””โ”€โ”€ labels
    โ”œโ”€โ”€ test
    โ”‚   โ”œโ”€โ”€ Cars27.txt
    โ”‚   โ”œโ”€โ”€ ...
    โ”œโ”€โ”€ train
    โ”‚   โ”œโ”€โ”€ Cars0.txt
    โ”‚   โ”œโ”€โ”€ ...
    โ””โ”€โ”€ validation
        โ”œโ”€โ”€ Cars10.txt
        โ”œโ”€โ”€ ...

Train YOLOv8 Object Detection Model on a Custom Dataset

To train your own object detection model, you can run:

python main.py

You can customize the following arguments:

  • -rpr or --remove_prev_runs: Whether you want to remove previous runs.
  • -p or --prepare: Whether you want to implement data preparation.
  • -t or --train: Whether you want to implement training.
  • -e or --export: Whether you want to export a saved model.

Inference with Trained Models

To get predictions from a YOLO saved model, run:

python inference.py --model_path 'path/to/model' --image_path 'path/to/test_image' --output_name 'output.png'

The default path for the saved model is runs/detect/train/weights/best.pt. The test image can be in jpg or png format. The result of the model's predicted bounding boxes will be saved in the runs directory as a png file.

Note: You might need to change datasets_dir, weights_dir, or runs_dir in .config/Ultralytics/settings.yaml based on the root of your project.

Also for getting predictions from a YOLO saved model on test videos you can run:

python inference.py --model_path 'path/to/model' --video_path 'path/to/test_video' --output_name 'output.avi'

car-plate-detection-yolov8's People

Contributors

elahehgolrokh avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.