python library to visualize object detection labels
Project description
labelvis
This is a small python utility to quickly visualize bounding-box annotations/labels before training models on the data.
Installation
From PyPI
pip install labelvis
From source
git clone https://github.com/satheeshkatipomu/labelvis.git
cd labelvis
pip install -e .
Usage
COCO
from labelvis.labelvis import LabelVisualizer
imgs_path = "./images"
annotations_path = "./annotations/trainval.json"
annotations_format = "coco" #["coco","pascal","manifest","yolo","simple_json"]
img_size = 256
labelvis = LabelVisualizer(imgs_path,annotations_path,annotations_format,img_size=img_size)
num_images = 9 #Number Images to Visualize
labelvis.show_batch(num_imgs=num_images)
Output
Input format
Images
Common for all annotations formats.
imgs_path = "/path/to/images"
/path/to/images
|_ img001.jpg
|_ img002.jpg
|_ img003.jpg
...
Annotations
COCO (x,y,w,h)
annotations_path = "/path/to/annotations/annotations.json"
Pascal
annotations_path = "/path/to/annotations"
/path/to/annotations
|_ img001.xml
|_ img002.xml
|_ img003.xml
...
Manifest (output from AWS Sagemaker groundtruth)
annotations_path = "/path/to/annotations/output.manifest"
Yolo
annotations_path = "/path/to/annotations"
/path/to/annotations
|_ img001.txt
|_ img002.txt
|_ img003.txt
...
Simple JSON
annotations_path = "/path/to/simple.json"
{
"image1.jpg": [
{
"bbox": [100, 11, 452, 332],
"confidence": 0.982,
"classname": "label1"
},
{
"bbox": [200, 0, 356, 89],
"confidence": 0.76,
"classname": "label2"
},
],
"image2.jpg": [
{
"bbox": [145, 120, 387, 221]
"confidence": 0.87,
"classname": "label2"
}
],
...
}
Filters
show_only_images_with_labels
#Load visualizer with any format
from labelvis.labelvis import LabelVisualizer
imgs_path = "../test/"
annotations_path = "./simple.json"
annotations_format = "simple_json" #["coco","pascal","manifest","yolo","simple_json"]
img_size = 1024
labelvis = LabelVisualizer(imgs_path,annotations_path,annotations_format,img_size=img_size)
#Show batch
num_images = 9 #Number Images to Visualize
labelvis.show_batch(num_imgs=num_images,show_only_images_with_labels=True) #Shows images with atleast one annotation.
show_only_images_with_no_labels
#Load visualizer with any format
from labelvis.labelvis import LabelVisualizer
imgs_path = "../test/"
annotations_path = "./simple.json"
annotations_format = "simple_json" #["coco","pascal","manifest","yolo","simple_json"]
img_size = 1024
labelvis = LabelVisualizer(imgs_path,annotations_path,annotations_format,img_size=img_size)
#Show batch
num_images = 9 #Number Images to Visualize
labelvis.show_batch(num_imgs=num_images,show_only_images_with_no_labels=True) #Shows images with no annotation.
filter_categories
#Load visualizer with any format
imgs_path = "./images/"
annotations_path = "./output.manifest"
annotations_format = "manifest" #["coco","pascal","manifest","yolo","simple_json"]
img_size = 512
labelvis = LabelVisualizer(imgs_path,annotations_path,annotations_format,img_size=img_size)
print(labelvis.dataloader.class_map)
{0: 'category1', 2: 'category2', 1: 'category3', 4: 'category4', 3: 'category5'}
#Show batch
num_images = 9 #Number Images to Visualize
labelvis.show_batch(num_imgs=num_images,filter_categories=[4,3]) #Shows images with only category 4 and 3 annotations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
labelvis-0.1.0.tar.gz
(10.0 kB
view details)
Built Distribution
labelvis-0.1.0-py3-none-any.whl
(11.0 kB
view details)
File details
Details for the file labelvis-0.1.0.tar.gz
.
File metadata
- Download URL: labelvis-0.1.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dd217e19e4bf06fb55907fb9d40e08710ee36c85289fa566a5c12b93490ce68 |
|
MD5 | b70148d7c37aeed7239d8e4f476808b9 |
|
BLAKE2b-256 | 65b3478abb2b2276ec051a7dde59a345656b6f5c4491e728bc6ff17024889145 |
File details
Details for the file labelvis-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: labelvis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61f26f0019de60ea96d372dc36c375e0f14662b4774a17c932c01341250a4937 |
|
MD5 | 92aa2bf4547fbfa3cc056532d88ec11c |
|
BLAKE2b-256 | 848b509b12b00b5b3c913e74241b82d33afe7568d4756380982b8a7996b791e6 |