Skip to main content

Draws boxes on images from annotations in YOLO format

Project description

pypi badge testing badge coverage badge docs badge black badge

Draws boxes on images from annotations in YOLO format.

Installation

Install using pip:

pip install drawyolo

Or directly from the repository:

pip install git+https://github.com/rbturnbull/drawyolo.git

Drawing boxes from labels

If you have a label file in YOLO format like this:

class_id x_center y_center width height

For example:

0 0.35 0.35 0.14 0.14
0 0.55 0.3 0.14 0.14
1 0.7 0.15 0.2 0.2

Then you can draw the boxes on an image like this:

drawyolo image.jpg output.jpg --labels labels.txt --classes class1,class2

To try it out on the image in the repository:

drawyolo tests/test-data/terrier.webp tests/test-data/output.jpg --labels tests/test-data/labels.txt --classes eye,ear

That will create an image like this:

Output image

To resize the image, use the --width and/or --height options. The aspect ratio will be preserved if you do not set both --width and --height.

For example:

drawyolo tests/test-data/terrier.webp tests/test-data/output-thumbnail.jpg --labels tests/test-data/labels.txt --classes eye,ear --width 240
Output image thumbnail

The thickness of the line will be set according to the final size of the image. You can change the thickness with the --line-thickness option.

Drawing boxes from a YOLO model

If you have a YOLO model with weights, you can draw the boxes on an image like this:

drawyolo image.jpg output.jpg --weights model.pt

You can also resize the image as before with the --width and --height options.

Advanced usage

For more options see the help

drawyolo --help

Credits

Robert Turnbull (Melbourne Data Analytics Platform) - https://robturnbull.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drawyolo-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drawyolo-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file drawyolo-0.1.1.tar.gz.

File metadata

  • Download URL: drawyolo-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.2.0

File hashes

Hashes for drawyolo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3ecfffdda16ccdee1d6f29d537bbbb5eead54220f5eadfc97ef64bbe7dc03b0e
MD5 ca01a4daf9efebe75b65dcd553ad6f2e
BLAKE2b-256 916ff9b2c2f8c90df1b7a23c8ac95f989281867a64c27c75d79f51b9c9b07ece

See more details on using hashes here.

File details

Details for the file drawyolo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: drawyolo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.2.0

File hashes

Hashes for drawyolo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7765ef926361db530600bd84151f3a40c5606d90048d28235ac94aa758cc3fb
MD5 a1954ce49f5cd8ef61469a7674038930
BLAKE2b-256 b892e299c54d87b98fb8cbb10ca0da57ff1ddbca4230190d0153fda6b540324d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page