g-loubna commited on
Commit ·
752e57e
1
Parent(s): c5bce9d
Add README with Space metadata
Browse files
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Bridge Semantic Segmentation
|
| 3 |
+
emoji: 🛰️
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: gray
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.37.2
|
| 8 |
+
python_version: 3.10
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
license: apache-2.0
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Bridge Semantic Segmentation (UNet++)
|
| 15 |
+
|
| 16 |
+
This Space provides an interactive Gradio interface for a UNet++ segmentation model that classifies bridge imagery into:
|
| 17 |
+
- background
|
| 18 |
+
- beton
|
| 19 |
+
- steel
|
| 20 |
+
|
| 21 |
+
Model weights are stored separately in the Hugging Face model repository: `g-loubna/bridge-unetpp`.
|
| 22 |
+
On first launch the Space will download the ~812 MB weight file; subsequent runs use the cached copy.
|
| 23 |
+
|
| 24 |
+
## Features
|
| 25 |
+
- Multiple visualization modes: Colored Mask, Overlay, Raw Class Indices
|
| 26 |
+
- Adjustable overlay opacity
|
| 27 |
+
- Adjustable background transparency in Colored Mask mode
|
| 28 |
+
- Pixel counts and class percentage statistics
|
| 29 |
+
- Downloadable raw mask (PNG)
|
| 30 |
+
- Option to output downsized mask for quicker experimentation
|
| 31 |
+
|
| 32 |
+
## How It Works
|
| 33 |
+
1. User uploads an RGB image.
|
| 34 |
+
2. Image is passed through the UNet++ model (PyTorch).
|
| 35 |
+
3. Predicted class mask is post-processed and rendered in the selected visualization mode.
|
| 36 |
+
4. Legend and statistics are generated dynamically.
|
| 37 |
+
|
| 38 |
+
## Repository Structure
|
| 39 |
+
- `app.py` – Gradio UI + weight download logic
|
| 40 |
+
- `inference.py` – Model loading / prediction helper
|
| 41 |
+
- `model.py` – Model architecture definition (or wrapper)
|
| 42 |
+
- `style.css` – Custom styling
|
| 43 |
+
- `requirements.txt` – Python dependencies
|
| 44 |
+
|
| 45 |
+
## Dependencies
|
| 46 |
+
See `requirements.txt`. Key packages:
|
| 47 |
+
- gradio
|
| 48 |
+
- torch
|
| 49 |
+
- segmentation-models-pytorch
|
| 50 |
+
- timm
|
| 51 |
+
- numpy
|
| 52 |
+
- Pillow
|
| 53 |
+
- huggingface-hub
|
| 54 |
+
|
| 55 |
+
## Notes
|
| 56 |
+
- First load may take several minutes (weight download). Subsequent refreshes are faster.
|
| 57 |
+
- If you update the model repo weights, just keep the same filename or adjust `WEIGHTS_FILENAME` in `app.py`.
|
| 58 |
+
|
| 59 |
+
## License
|
| 60 |
+
Provided under the Apache-2.0 License (see `license` field above). Change this field and add a LICENSE file if you prefer MIT or another OSI-approved license.
|
| 61 |
+
|
| 62 |
+
## TODO (Future Enhancements)
|
| 63 |
+
- Add more classes
|
| 64 |
+
- Add batch upload
|
| 65 |
+
- Add evaluation metrics (IoU per class) on a sample set
|