Giter Club home page Giter Club logo

yihong1120 / yolov8-postprocessing-prcurve Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 234 KB

This repository contains code for post-processing techniques and PR curve visualization for object detection using YOLOv8. The project aims to improve object detection results through advanced post-processing methods and provides an analysis of precision and recall using PR curves.

License: GNU Affero General Public License v3.0

Python 98.24% Shell 1.76%
computer-vision data-analysis post-processing python yolov8 deep-learning image-recognition machine-learning object-detection pr-curve

yolov8-postprocessing-prcurve's Introduction

YOLOv8-PostProcessing-PRCurve

This repository contains code for post-processing techniques and PR curve visualization for object detection using YOLOv8. The project aims to improve object detection results through advanced post-processing methods and provides an analysis of precision and recall using PR curves.

The YOLOv8 model used in this project is sourced from the Ultralytics repository.

Contents

File Organisation

The repository is organised as follows:

YOLOv8-PostProcessing-PRCurve/
├── images/
│   ├── yolov8_postprocess.png
│   └── PR-curves.png
├── scripts/
│   ├── yolo_label_converter.py
│   ├── yolo_inference_and_postprocessing.py
│   ├── pr_curve_validation.py
│   └── run_scripts.sh
├── README.md
├── requirements.txt
├── y_preds.pkl
└── y_true.pkl
  • The 'images' folder contains images related to the project, such as the process flowchart ('yolov8_postprocess.png') and the PR curves ('PR-curves.png').

  • The 'scripts' folder contains the following Python scripts:

    • 'yolo_label_converter.py': Converts YOLOv8 labels to regular bounding box coordinates.
    • 'yolo_inference_and_postprocessing.py': Performs object detection and post-processing using YOLOv8.
    • 'pr_curve_validation.py': Calculates precision and recall values and plots PR curves.
    • 'run_scripts.sh': Bash script for running the necessary scripts in the correct order.
  • The 'README.md' file is the project's main documentation.

  • The 'requirements.txt' file lists the required dependencies for the project.

  • The 'y_preds.pkl' and 'y_true.pkl' files contain the predicted and ground truth bounding box data, respectively.

Installation

  1. Clone the repository:
git clone https://github.com/yihong1120/YOLOv8-PostProcessing-PRCurve.git
cd YOLOv8-PostProcessing-PRCurve
  1. Install the required dependencies:
pip install -r requirements.txt

Label Conversion

The 'yolo_label_converter.py' file provides functions to convert YOLOv8 coordinates to regular bounding box coordinates. It reads text files containing bounding box information and converts them to a pickle file for further processing.

To use the label converter, modify the 'folder_path' variable in the 'main()' function to point to the directory containing the label files. Then run the script:

python scripts/yolo_label_converter.py

The converted labels will be saved as 'y_true.pkl'.

Inference and Post-processing

The 'yolo_inference_and_postprocessing.py' file extends the YOLOv8 'detect/val.py' script. It performs object detection on images using a trained YOLOv8 model and applies post-processing techniques such as OCR and aspect ratio correction.

To use the inference and post-processing script, make sure to update the 'model' and 'source' variables in the 'predict()' function with the appropriate paths. Then run the script:

python scripts/yolo_inference_and_postprocessing.py

The predicted results will be saved as 'y_preds.pkl'. The process flowchart illustrating the post-processing steps in the 'yolo_inference_and_postprocessing.py' script is shown below:

here

The flowchart above illustrates the post-processing steps performed in the 'yolo_inference_and_postprocessing.py' script. It shows the sequence of operations, including OCR, aspect ratio correction, and other specific post-processing tasks.

PR Curve Validation

The 'pr_curve_validation.py' file calculates precision and recall values from the predicted and ground truth bounding boxes and plots PR curves for each class.

To validate the predicted results, make sure to have 'y_preds.pkl' and 'y_true.pkl' files in the repository. Then run the script:

python scripts/pr_curve_validation.py

The PR curves will be displayed in the console. A visualisation of the PR curves generated by 'pr_curve_validation.py' is shown below:

here

Feel free to explore and modify the code to suit your needs for post-processing and PR curve analysis in object detection using YOLOv8.

Run Scripts

To conveniently run the necessary scripts, you can use the run_scripts.sh file provided in this repository. This bash script automates the execution of the required scripts in the correct order.

To run the scripts, navigate to the repository directory and execute the following command:

bash scripts/run_scripts.sh

The script will run the following scripts in sequence:

  1. 'yolo_label_converter.py': Converts YOLOv8 labels to regular bounding box coordinates.
  2. 'yolo_inference_and_postprocessing.py': Performs object detection and post-processing using YOLOv8.
  3. 'pr_curve_validation.py': Calculates precision and recall values and plots PR curves. Make sure to have the necessary input files in the repository before running the scripts.

Feel free to explore and modify the code to suit your needs for post-processing and PR curve analysis in object detection using YOLOv8.

Generated Files

The following files will be generated during the execution of the scripts:

  • 'y_preds.pkl': Contains the predicted bounding box data.
  • 'y_true.pkl': Contains the ground truth bounding box data. Please ensure that the 'y_preds.pkl' and 'y_true.pkl' files are present in the repository for PR curve validation.

License

This project is licensed under the AGPL-3.0.

yolov8-postprocessing-prcurve's People

Contributors

yihong1120 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.