A vision library for performing sliced inference on large images/small objects
Project description
SAHI: Slicing Aided Hyper Inference
A vision library for performing sliced inference on large images/small objects
Overview
Object detection and instance segmentation are by far the most important fields of applications in Computer Vision. However, detection of small objects and inference on large images are still major issues in practical usage. Here comes the SAHI to help developers overcome these real-world problems.
Getting started
Blogpost
Check the official SAHI blog post.
Installation
- Install sahi using conda:
conda install -c obss sahi
- Install sahi using pip:
pip install sahi
- Install your desired version of pytorch and torchvision:
pip install torch torchvision
- Install your desired detection framework (such as mmdet):
pip install mmdet
Usage
- Sliced inference:
result = get_sliced_prediction(
image,
detection_model,
slice_height = 256,
slice_width = 256,
overlap_height_ratio = 0.2,
overlap_width_ratio = 0.2
)
Refer to inference notebook for detailed usage.
- Slice an image:
from sahi.slicing import slice_image
slice_image_result, num_total_invalid_segmentation = slice_image(
image=image_path,
output_file_name=output_file_name,
output_dir=output_dir,
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)
- Slice a coco formatted dataset:
from sahi.slicing import slice_coco
coco_dict, coco_path = slice_coco(
coco_annotation_file_path=coco_annotation_file_path,
image_dir=image_dir,
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)
Refer to slicing notebook for detailed usage.
Scripts
Find detailed info on script usage (predict, coco2yolov5, coco_error_analysis) at SCRIPTS.md.
COCO Utilities
Find detailed info on COCO utilities (yolov5 conversion, slicing, subsampling, merging, splitting) at COCO.md.
Adding new detection framework support
sahi library currently only supports MMDetection models. However it is easy to add new frameworks.
All you need to do is, creating a new class in model.py that implements DetectionModel class. You can take the MMDetection wrapper as a reference.
Contributers
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sahi-0.3.5.tar.gz
.
File metadata
- Download URL: sahi-0.3.5.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e166284063aa263b09b4a48721e46b91737ca92d63e99ade8feee070b84c6a86 |
|
MD5 | 251c62854d8250ec54b9117f1e8570e4 |
|
BLAKE2b-256 | 618f7a90a92954f96c42df285ec8541cbe16acc40fd43b6c124a14feca773709 |
File details
Details for the file sahi-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: sahi-0.3.5-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 517a464c435d475d0530ae4a5a8272943aaaeff64774b45ba936d81db5bced19 |
|
MD5 | 3c7dbed8fe1c1c55a07bcd7bb4327f42 |
|
BLAKE2b-256 | 6119e016917b5b74c7fb03643929194971c9ac49acc8cfa0f72350077b297229 |