v0.7.3
enhancements
-
handle negative bbox coords, utilize image_size param (#188)
-
add get_upsampled_coco utility to Coco (#189)
-
add category and negative sample based coco up/sub-sampling (#191)
-
Subsample COCO dataset file:
from sahi.utils.coco import Coco
# specify coco dataset path
coco_path = "coco.json"
# init Coco object
coco = Coco.from_coco_dict_or_path(coco_path)
# create a Coco object with 1/10 of total images
subsampled_coco = coco.get_subsampled_coco(subsample_ratio=10)
# export subsampled COCO dataset
save_json(subsampled_coco.json, "subsampled_coco.json")
# bonus: create a Coco object with 1/10 of total images that contain first category
subsampled_coco = coco.get_subsampled_coco(subsample_ratio=10, category_id=0)
# bonus2: create a Coco object with negative samples reduced to 1/10
subsampled_coco = coco.get_subsampled_coco(subsample_ratio=10, category_id=-1)
- Upsample COCO dataset file:
from sahi.utils.coco import Coco
# specify coco dataset path
coco_path = "coco.json"
# init Coco object
coco = Coco.from_coco_dict_or_path(coco_path)
# create a Coco object with each sample is repeated 10 times
upsampled_coco = coco.get_upsampled_coco(upsample_ratio=10)
# export upsampled COCO dataset
save_json(upsampled_coco.json, "upsampled_coco.json")
# bonus: create a Coco object with images that contain first category repeated 10 times
subsampled_coco = coco.get_subsampled_coco(upsample_ratio=10, category_id=0)
# bonus2: create a Coco object with negative samples upsampled by 10 times
upsampled_coco = coco.get_upsampled_coco(upsample_ratio=10, category_id=-1)