Framework agnostic sliced/tiled inference + interactive ui + error analysis plots
MIT License
Bot releases are visible (Hide)
Published by fcakyon almost 3 years ago
read_image_as_pil
by @fcakyon in https://github.com/obss/sahi/pull/283
Full Changelog: https://github.com/obss/sahi/compare/0.8.10...0.8.11
Published by fcakyon almost 3 years ago
Full Changelog: https://github.com/obss/sahi/compare/0.8.9...0.8.10
Published by fcakyon almost 3 years ago
improve result visuals/plots by @fcakyon in https://github.com/obss/sahi/pull/271
add get_coco_with_clipped_bboxes
utility to coco class by @ssahinnkadir in https://github.com/obss/sahi/pull/264
fix mmdet channel order by @fcakyon in https://github.com/obss/sahi/pull/266
handle when mask prediction is empty by @fcakyon in https://github.com/obss/sahi/pull/269
handle invalid annotation polygon by @fcakyon in https://github.com/obss/sahi/pull/268
add missing shapely 2.0.0 support by @fcakyon in https://github.com/obss/sahi/pull/270
update torch, torchvision, mmdet, mmcv versions in tests by @fcakyon in https://github.com/obss/sahi/pull/267
Full Changelog: https://github.com/obss/sahi/compare/0.8.8...0.8.9
Published by fcakyon almost 3 years ago
Published by fcakyon about 3 years ago
Published by fcakyon about 3 years ago
Published by fcakyon about 3 years ago
Remove invalid coco results:
from sahi.utils.file import save_json
from sahi.utils.coco import remove_invalid_coco_results
# remove invalid predictions from COCO results JSON
coco_results = remove_invalid_coco_results("coco_result.json")
# export processed COCO results
save_json(coco_results, "fixed_coco_result.json")
# bonus: remove invalid predictions from COCO results JSON by giving COCO
# dataset path to also filter out bbox results exceeding image height&width
coco_results = remove_invalid_coco_results("coco_result.json", "coco_dataset.json")
Published by fcakyon about 3 years ago
Published by fcakyon about 3 years ago
Published by fcakyon about 3 years ago
make repo compatible for conda-forge:
Published by fcakyon about 3 years ago
Command | Description |
---|---|
predict | perform sliced/standard prediction using any yolov5/mmdet model |
predict-fiftyone | perform sliced/standard prediction using any yolov5/mmdet model and explore results in fiftyone app |
coco slice | automatically slice COCO annotation and image files |
coco fiftyone | explore multiple prediction results on your COCO dataset ordered by false positives |
coco evaluate | evaluate classwise COCO AP and AR for given predictions and ground truth |
coco analyse | calcualate and export many detection and segmentation error margin plots |
coco yolov5 | automatically convert any COCO dataset to yolov5 format |
sahi predict --source image/file/or/folder --model_path path/to/model --model_config_path path/to/config
sahi predict-fiftyone --image_dir image/file/or/folder --dataset_json_path dataset.json --model_path path/to/model --model_config_path path/to/config
sahi coco slice --image_dir dir/to/images --dataset_json_path dataset.json
sahi coco fiftyone --image_dir dir/to/images --dataset_json_path dataset.json cocoresult1.json cocoresult2.json
sahi coco evaluate --dataset_json_path dataset.json --result_json_path result.json
sahi coco analyse --dataset_json_path dataset.json --result_json_path result.json
sahi coco yolov5 --image_dir dir/to/images --dataset_json_path dataset.json --train_split 0.9
predict cli
:config_path
to model_config_path
conf_thresh
to model_confidence_threshold
match_metric
to postprocess_match_metric
match_thresh
to postprocess_match_threshold
class_agnostic
to postprocess_class_agnostic
pickle
to export_pickle
, crop
to export_crop
novisual
to export_visual
no_sliced_pred
to no_sliced_prediction
no_standard_pred
to no_standard_prediction
coco_file
to dataset_json_path
Published by fcakyon about 3 years ago
Published by fcakyon about 3 years ago
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)
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)
Published by fcakyon about 3 years ago
Published by fcakyon about 3 years ago
Published by fcakyon over 3 years ago
in predict
and predict_fiftyone
funtions:
model_name
arg with model_type
model_parameters
arg with model_path, model_config_path, model_confidence_threshold, model_device, model_category_mapping, model_category_remapping
in DetectionModel base class:
prediction_score_threshold
arg with confidence_threshold
updated demo notebooks accordingly
Published by fcakyon over 3 years ago
Example usages:
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
)
Published by fcakyon over 3 years ago
Published by fcakyon over 3 years ago
coco_evaluation.py
script usage:python scripts/coco_evaluation.py dataset.json results.json
will calculate coco evaluation and export them to given output folder directory.
If you want to specify mAP metric type, set it as --metric bbox mask
.
If you want to also calculate classwise scores add --classwise
argument.
If you want to specify max detections, set it as --proposal_nums 10 100 500
.
If you want to specify a psecific IOU threshold, set it as --iou_thrs 0.5
. Default includes 0.50:0.95
and 0.5
scores.
If you want to specify export directory, set it as --out_dir output/folder/directory
.
coco_error_analysis.py
script usage:
python scripts/coco_error_analysis.py dataset.json results.json
will calculate coco error plots and export them to given output folder directory.
If you want to specify mAP result type, set it as --types bbox mask
.
If you want to export extra mAP bar plots and annotation area stats add --extraplots
argument.
If you want to specify area regions, set it as --areas 1024 9216 10000000000
.
If you want to specify export directory, set it as --out_dir output/folder/directory
.
--no_sliced_pred
argument. If you don't want to perform standard prediction add --no_standard_pred
argument.Published by fcakyon over 3 years ago