imgutils.segment.isnetis

Overview:

Anime character segmentation, based on https://huggingface.co/skytnt/anime-seg .

get_isnetis_mask

imgutils.segment.isnetis.get_isnetis_mask(image: str | PathLike | bytes | bytearray | BinaryIO | Image, scale: int = 1024)[source]
Overview:

Get mask with isnetis.

Parameters:
Returns:

Get a mask with all the pixels, which shape is (H, W).

segment_with_isnetis

imgutils.segment.isnetis.segment_with_isnetis(image: str | PathLike | bytes | bytearray | BinaryIO | Image, background: str = 'lime', scale: int = 1024)[source]
Overview:

Segment image with pure color background.

Parameters:
Returns:

The mask and An RGB image featuring a pure-colored background along with a segmented image.

Examples::
>>> from imgutils.segment import segment_with_isnetis
>>>
>>> mask_, image_ = segment_with_isnetis('hutao.png')
>>> image_.save('hutao_seg.png')
>>>
>>> mask_, image_ = segment_with_isnetis('skadi.jpg', background='white')  # white background
>>> image_.save('skadi_seg.jpg')

The result should be

../../_images/isnetis_color.plot.py.svg

segment_rgba_with_isnetis

imgutils.segment.isnetis.segment_rgba_with_isnetis(image: str | PathLike | bytes | bytearray | BinaryIO | Image, scale: int = 1024)[source]
Overview:

Segment image with transparent background.

Parameters:
Returns:

The mask and An RGBA image featuring a transparent background along with a segmented image.

Examples::
>>> from imgutils.segment import segment_rgba_with_isnetis
>>>
>>> mask_, image_ = segment_rgba_with_isnetis('hutao.png')
>>> image_.save('hutao_seg.png')
>>>
>>> mask_, image_ = segment_rgba_with_isnetis('skadi.jpg')
>>> image_.save('skadi_seg.png')

The result should be

../../_images/isnetis_trans.plot.py.svg