Skip to content

Instantly share code, notes, and snippets.

@mrdbourke
Last active April 25, 2020 06:42
Show Gist options
  • Save mrdbourke/d4bb50db7ac571657f7692eb125f2632 to your computer and use it in GitHub Desktop.
Save mrdbourke/d4bb50db7ac571657f7692eb125f2632 to your computer and use it in GitHub Desktop.
# Create list of validation image dictionaries
val_img_dicts = get_image_dicts(image_folder="validation", # validation images
annotation_file="validation-annotations-bbox.csv", # these get formatted automatically
target_classes=target_classes) # list of target classes you're working with
>>> Using validation-annotations-bbox.csv for annotations...
On dataset: validation/
Classes we're using:
Coffeemaker 21
Name: ClassName, dtype: int64
Total number of images: 21
Saving labels to: validation/valid_labels.json... # files get saved to JSON for later
Showing an example:
[{'annotations': [{'bbox': [2.0, 173.0, 1008.0, 768.0],
'bbox_mode': <BoxMode.XYXY_ABS: 0>,
'category_id': 1}],
'file_name': './cmaker-fireplace-valid/c86feb2143de77e7.jpg',
'height': 768,
'image_id': 50,
'width': 1024}]
CPU times: user 1.46 s, sys: 25.1 ms, total: 1.49 s
Wall time: 1.49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment