Skip to content

A simple utility to crop from PNG or JPEG images bounding box annotations in PASCAL VOC formatted annotations. This is useful to extract images (and resize them) for classification testing.

Notifications You must be signed in to change notification settings

mbari-org/voc-cropper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MBARI

semantic-release Supported Platforms license-GPL

About

voc-imagecropper is a simple utility to crop from PNG or JPEG images bounding box annotations in PASCAL VOC formatted annotations. This is used to crop (and optionally resize) images from full frames for classification testing.

 Image link

Arguments

  • run as you: -u $(id -u):$(id -g)
  • remove after running: --rm
  • run interactively: -it
  • --resize the cropped image to the specified size, e.g. --resize 128x128 crop then resizes to 128x128
  • -d root directory to the raw data
  • -o path to output image crops to
  • --minsize minimum size pixel width or height dimension - useful to remove images too small for classification
  • (optional) --labels list of space separated labels to load - defaults to everything.
  • (optional) --image_dir path where raw images associated with the annotations are located - overrides those defined in the PASCAL formatted annotations

Build

You can skip this step if you are using the pre-built docker image.

docker build -t mbari/voc-imagecropper .

Run example

docker run -it \
--rm -u $(id -u):$(id -g) \
-v $PWD/data:/data mbari/voc-imagecropper \
-d /data/annotations \
--image_dir /data/imgs \
-o /data/out

Should see output similar to:

2023-07-17 22:06:09,885 INFO Searching in data/annotations for .xml files
2023-07-17 22:06:09,886 INFO Found 1 files
2023-07-17 22:06:09,886 INFO Using 1 processes to convert 1 annotations ...
2023-07-17 22:06:10,341 INFO Calculating mean and std ...
2023-07-17 22:06:10,341 INFO Computing statistics for data
Computing statistics for data : 100% (1 of 1) || Elapsed Time: 0:00:00 Time:  0:00:00
2023-07-17 22:06:10,491 INFO Writing data/stats.txt
2023-07-17 22:06:10,492 INFO Number of concepts: 1
2023-07-17 22:06:10,492 INFO Number of frames: 1
2023-07-17 22:06:10,492 INFO Mean: [0.33466873 0.40399225 0.39004853]
2023-07-17 22:06:10,492 INFO Std: [0. 0. 0.]
2023-07-17 22:06:10,492 INFO Writing data/labels.txt

About

A simple utility to crop from PNG or JPEG images bounding box annotations in PASCAL VOC formatted annotations. This is useful to extract images (and resize them) for classification testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published