File size: 1,603 Bytes
cdd7eee
 
 
 
 
fb457a7
3115638
fb457a7
1b1e5a0
cdd7eee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3115638
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: Instance Segmentation Demo
emoji: ๐Ÿ–ผ๏ธ
colorFrom: pink
colorTo: purple
sdk: gradio
sdk_version: 5.34.2
app_file: app.py
pinned: false
---

# ๐Ÿ–ผ๏ธ Instance Segmentation with Mask2Former

This demo performs **advanced instance segmentation** using [Mask2Former](https://huggingface.co/facebook/mask2former-swin-large-coco-instance) from Facebook AI. It identifies and highlights individual objects in an image with:
- **Colored masks**
- **Bounding boxes**
- **Class labels and confidence scores**

## ๐Ÿš€ How It Works

- Input an image via upload or example selection.
- The app uses the `facebook/mask2former-swin-large-coco-instance` model to detect objects.
- Only the following classes are visualized:
  - `cat`, `dog`, `car`, `truck`, `bus`, `person`
- Results are drawn on the image and displayed along with a status message.

## ๐Ÿง  Model

- **Architecture:** Mask2Former with Swin-Large backbone
- **Dataset:** COCO Instance
- **Framework:** Hugging Face Transformers + PyTorch

## ๐Ÿ’ป Technologies Used

- Python ๐Ÿ
- [Gradio](https://gradio.app) for UI
- Hugging Face Transformers
- PIL & NumPy for image manipulation

## ๐Ÿ“ท Example Images

Try out with example images like:
- Cats vs. Dogs
- Street scenes with vehicles and people

You can also upload your own images!

## ๐Ÿ“Œ Notes

- Detection is limited to high-confidence predictions (`score > 0.9`)
- This demo is optimized for CPU; inference may take up to 30 seconds.

---

## ๐Ÿ› ๏ธ Developer Notes

This app uses the following Gradio configuration:

```yaml
sdk: gradio
sdk_version: "4.24.0"
app_file: app.py