Sahi

Latest version: v0.11.19

Safety actively analyzes 682361 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 10 of 16

0.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)

- <big><b>Subsample COCO dataset file:</b></big>

python
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)


- <big><b>Upsample COCO dataset file:</b></big>

python
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)

0.7.2

- add large tiff image reading support (183)
- add concurrent slice export (184)

0.7.1

- fix segmentation slicing (174)

0.7.0

- refactor predict api (170)

breaking changes

in `predict` and `predict_fiftyone` funtions:
- replaced `model_name` arg with `model_type`
- replaced `model_parameters` arg with `model_path, model_config_path, model_confidence_threshold, model_device, model_category_mapping, model_category_remapping`

in DetectionModel base class:
- replaced `prediction_score_threshold` arg with `confidence_threshold`

updated demo notebooks accordingly

0.6.2

- add input size parameter for inference (169)

Example usages:

python

detection_model = Yolov5DetectionModel(
model_path=yolov5_model_path,
device="cpu", or 'cuda'
)

result = detection_model.perform_inference(
image,
image_size=1280
)

result = get_prediction(
"demo_data/small-vehicles1.jpeg",
detection_model,
image_size=1280
)

result = get_sliced_prediction(
"demo_data/small-vehicles1.jpeg",
detection_model,
image_size=1280,
slice_height = 256,
slice_width = 256,
overlap_height_ratio = 0.2,
overlap_width_ratio = 0.2
)

0.6.1

- refactor slice_coco script (165)
- make default for ignore_negative_samples, False (166)

Page 10 of 16

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.