Coder Social home page Coder Social logo

faizan1234567 / crop-yolo-bounding-boxes Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

YOLO has many variants such as YOLOv5, YOLOv4, YOLOv7, and YOLOv8. Sometimes, it's important to use cropped annotations i.e. to train a second stage classifer etc.

Python 100.00%
bounding-boxes crop detections yolo unnormalized

crop-yolo-bounding-boxes's Introduction

Crop YOLO Bounding boxes

The script will crop the bounding box of YOLO models such as YOLOv4, YOLOv5, YOLOv7, and YOLOv8. YOLO annotations are normalized so it is tricky to crop the annotation if you have not done it before. The annotations have to be converted to unnormalized format to crop the label in an image. A sample label for a person is given as:

0 0.2344 0.7833 0.0343 0.89838

This is for just demonstration, it's not a true label. This is how YOLO format annotations look like. The first number (integer) is class label such as person in the example above. Second number is called "x" and it's bounding box's center coordinate, similary, third number (y) is also a center coordinate. And, rest two numbers are width (w) and height (h) of the bouding box.

This will transform the annotations to xyxy (unnormalized top left point and bottom right point) of the bouding box for cropping the label in an image.

Installation

To install the repository, run following commands.

https://github.com/faizan1234567/Crop-YOLO-Bounding-Boxes.git
cd Crop-YOLO-Bounding-Boxes
pip install --upgrade pip
pip install -r requirements.txt

Usage

python crop_yolo_labels.py --images path_to_images_directory --save path_to_directory_to_save_crop_images --labels path_to_labels_directory

I will add more featuer to the repository like cropping yolo predictions etc. If it's useful for you, please star the repository.

crop-yolo-bounding-boxes's People

Contributors

faizan1234567 avatar

Watchers

 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.