Skip to main content

A vision library for performing sliced inference on large images/small objects

Project description

SAHI: Slicing Aided Hyper Inference

PyPI version Conda version CI

A vision library for performing sliced inference on large images/small objects

teaser

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

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

sahi-0.3.1.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

sahi-0.3.1-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

Details for the file sahi-0.3.1.tar.gz.

File metadata

  • Download URL: sahi-0.3.1.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for sahi-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7a37a24cb2436f5fc4050d226fe09dac9e43d29af54e6752a77a432c3a0ebca8
MD5 d00e2aa16e45dc0740580beee1bb416d
BLAKE2b-256 a4ac9d8b7640afa4633d4a3f53521d98de525557802678d1cd1d84ed484b81d2

See more details on using hashes here.

File details

Details for the file sahi-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: sahi-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 38.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for sahi-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a47bd4ca347335cffea9d875c0504d27263ed1ef75f84c8dbd2060e429d13887
MD5 761253737036e712ea18acb0d20bc1b4
BLAKE2b-256 9d8cb52cf2b3bf48e4bcca44b74c9e6b7be0d04aa7b6376d6d2fe2acd953a4a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page