https://github.com/bencevans/segment-animals
Segment (Extract) Animals from Images - Removing Background
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
Repository
Segment (Extract) Animals from Images - Removing Background
Basic Info
Statistics
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 1
Metadata Files
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)...

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:

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
- Website: https://bencevans.io/
- Twitter: bencevans
- Repositories: 282
- Profile: https://github.com/bencevans
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
- Documentation: https://segment-animals.readthedocs.io/
-
Latest release: 1.0.0
published 12 months ago
Rankings
Maintainers (1)
Dependencies
- megadetector >=5.0.29
- pillow >=11.2.1
- requests >=2.32.4
- segment-anything *
- 139 dependencies