GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • imgutils
  • Installation
  • Quick Start
  • Run Environment Information
  • imgutils.config
  • imgutils.ascii
  • imgutils.data
  • imgutils.detect
  • imgutils.edge
  • imgutils.generic
  • imgutils.metadata
  • imgutils.metrics
  • imgutils.ocr
  • imgutils.operate

This view

  • Original page
  • New address

GeezerVison is showing dghs-imgutils.deepghs.org — imgutils.segment.isnetis — imgutils 0.19.0 documentation

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:
  • image – Original image (assume its size is (H, W)).

  • scale – Scale when passing it into neural network. Default is 1024, inspired by https://huggingface.co/spaces/skytnt/anime-remove-background/blob/main/app.py#L8 .

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:
  • image – Original image (assume its size is (H, W)).

  • background – Background color for padding. Default is lime which represents #00ff00.

  • scale – Scale when passing it into neural network. Default is 1024, inspired by https://huggingface.co/spaces/skytnt/anime-remove-background/blob/main/app.py#L8 .

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:
  • image – Original image (assume its size is (H, W)).

  • scale – Scale when passing it into neural network. Default is 1024, inspired by https://huggingface.co/spaces/skytnt/anime-remove-background/blob/main/app.py#L8 .

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
Other Versions v: main
Tags
v0.14.0
v0.14.1
v0.15.0
v0.16.0
v0.17.0
v0.18.0
v0.18.1
v0.19.0
Branches
HEAD
dev/attachments
dev/pt
main
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.