https://github.com/wooyeolbaek/seg-mask-process
Segmentation mask postprocessing
https://github.com/wooyeolbaek/seg-mask-process
postprocess segmentation segmentation-masks
Last synced: 4 months ago
JSON representation
Segmentation mask postprocessing
- Host: GitHub
- URL: https://github.com/wooyeolbaek/seg-mask-process
- Owner: wooyeolBaek
- Created: 2023-10-14T08:12:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-28T00:26:17.000Z (about 1 year ago)
- Last Synced: 2024-05-28T09:55:27.126Z (about 1 year ago)
- Topics: postprocess, segmentation, segmentation-masks
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Post Process for Segmentation Masks
## Usage
Fill pixel areas below the specific threshold using Breadth First Search
## Initialize
```shell
python -m venv .seg_venv
source .seg_venv/bin/activate
pip install requirements.txt
mkdir masks
```
Put mask images inside the `masks` directory## (Optional)Normalize Mask
- Visualizing mask images
```shell
python norm.py
```## Process
```shell
python process.py
```## (Optional)CLIP Seg
- Quick Start: Segmentation Mask
```python
from PIL import Image
import requests
from transformers import AutoProcessor, CLIPSegModelprocessor = AutoProcessor.from_pretrained("CIDAS/clipseg-rd64-refined")
model = CLIPSegModel.from_pretrained("CIDAS/clipseg-rd64-refined")url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)inputs = processor(
text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True
)outputs = model(**inputs)
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
```## References
- https://github.com/switchablenorms/CelebAMask-HQ
- https://huggingface.co/docs/transformers/model_doc/clipseg
- https://huggingface.co/CIDAS/clipseg-rd64-refined