https://github.com/bencevans/segment-animals

Segment (Extract) Animals from Images - Removing Background

https://github.com/bencevans/segment-animals

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.5%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Segment (Extract) Animals from Images - Removing Background

Basic Info
  • Host: GitHub
  • Owner: bencevans
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage:
  • Size: 3.61 MB
Statistics
  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created 12 months ago · Last pushed 12 months ago
Metadata Files
Readme

README.md

Segment Animals

Segment Animals is a Python package for segmenting (extracting) animals from images using deep learning models. It provides a pipeline that combines object detection and segmentation to identify and extract animals from images, making it useful for wildlife research, conservation efforts, and any application where you wish to remove the background from images containing animals.

Segment Animals builds upon the Segment Anything and MegaDetector models.

Installation

You can install Segment Animals using pip:

bash pip install segment-animals

Usage

Here's a quick example of how to use Segment Animals, for a more detailed guide refer to the notebook.

Importing the library and processing an image

```python from segmentanimals import AutoAnimalSegmenter from segmentanimals.util import load_image

model = AutoAnimalSegmenter()

image = load_image("path/to/your/image.jpg")

detections, masks = model.process_image(image) print(f"Found {len(detections)} animals.") ```

Visualizing detections and masks

```python from segmentanimals.viz import plotdetectionsandmasks

plotdetectionsand_masks(image, detections, masks) ```

You should then see a visualisation along the lines of this (original image from Wikipedia)...

Example Segmentation

Extracting and saving masks

```python from segmentanimals.viz import extractmasks

Setting whole_image to False will return individual masks cropped to the extent

of the predicted masks.

for i, maskextract in enumerate(extractmasks(image, masks, wholeimage=False)): # maskextract is a PIL Image object so you can save it or manipulate it further maskextract.save(f"animalmask_{i}.png") ```

Resulting in something like this:

Example Mask

Working with Segment Animals?

It'd be great to hear how you're using Segment Animals! Drop me a line at Benjamin.Evans at ioz.ac.uk or open an issue on the GitHub repository.

Owner

  • Name: Ben Evans
  • Login: bencevans
  • Kind: user
  • Location: London, UK
  • Company: Institute of Zoology, ZSL

GitHub Events

Total
  • Watch event: 3
  • Public event: 1
Last Year
  • Watch event: 3
  • Public event: 1

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 94 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
pypi.org: segment-animals

Segment (Extract) Animals from Images - Removing Background

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 94 Last month
Rankings
Dependent packages count: 8.9%
Average: 29.6%
Dependent repos count: 50.3%
Maintainers (1)
Last synced: 11 months ago

Dependencies

pyproject.toml pypi
  • megadetector >=5.0.29
  • pillow >=11.2.1
  • requests >=2.32.4
  • segment-anything *
uv.lock pypi
  • 139 dependencies