Delete README.md
Browse files
README.md
DELETED
@@ -1,89 +0,0 @@
|
|
1 |
-
# Skin Lesion Segmentation API with Uncertainty Estimation
|
2 |
-
|
3 |
-
This repository contains a production-ready FastAPI service for performing semantic segmentation of skin lesions, trained on the ISIC 2018 dataset. The segmentation model uses a Swin-Tiny transformer encoder with a custom UPerNet decoder, and incorporates Monte Carlo (MC) Dropout at inference time to estimate predictive uncertainty.
|
4 |
-
|
5 |
-
## Features
|
6 |
-
|
7 |
-
- RESTful FastAPI endpoint for real-time image segmentation
|
8 |
-
- Swin-Tiny + UPerNet architecture for accurate lesion boundary detection
|
9 |
-
- Monte Carlo Dropout-based uncertainty quantification
|
10 |
-
- Heatmap visualization of model uncertainty using OpenCV colormaps
|
11 |
-
- Side-by-side output of the predicted segmentation mask and uncertainty map
|
12 |
-
- Clean, modular codebase suitable for further extension and deployment
|
13 |
-
|
14 |
-
## Inference Workflow
|
15 |
-
|
16 |
-
1. The API accepts a dermoscopic image uploaded via a POST request to the `/predict/` endpoint.
|
17 |
-
2. The image is resized, normalized, and passed through the segmentation model.
|
18 |
-
3. The model performs multiple stochastic forward passes using MC Dropout.
|
19 |
-
4. The mean prediction is binarized to produce a segmentation mask.
|
20 |
-
5. The standard deviation across predictions is visualized as a heatmap to express uncertainty.
|
21 |
-
6. The API returns both the binary mask and uncertainty heatmap as a combined PNG image.
|
22 |
-
|
23 |
-
## File Structure
|
24 |
-
|
25 |
-
| File | Description |
|
26 |
-
|-------------------|--------------------------------------------------------------|
|
27 |
-
| `main.py` | FastAPI application and endpoint logic |
|
28 |
-
| `model.py` | Model architecture and MC Dropout inference utilities |
|
29 |
-
| `requirements.txt`| Required Python packages |
|
30 |
-
| `.gitignore` | Specifies ignored files (e.g., `venv/`, model weights) |
|
31 |
-
|
32 |
-
## Requirements
|
33 |
-
|
34 |
-
- Python 3.9+
|
35 |
-
- PyTorch
|
36 |
-
- FastAPI
|
37 |
-
- OpenCV
|
38 |
-
- Pillow
|
39 |
-
- timm
|
40 |
-
- torchvision
|
41 |
-
- uvicorn
|
42 |
-
|
43 |
-
Install dependencies:
|
44 |
-
|
45 |
-
```bash
|
46 |
-
pip install -r requirements.txt
|
47 |
-
```
|
48 |
-
|
49 |
-
|
50 |
-
## Model Weights
|
51 |
-
|
52 |
-
To run the API, you will need to download the pretrained model weights and place the file in the root directory of this repository.
|
53 |
-
|
54 |
-
**Download link:**
|
55 |
-
|
56 |
-
[best_swin_upernet_main.pth](https://huggingface.co/samyakshrestha/swin-medical-segmentation/resolve/main/best_swin_upernet_main.pth?download=true)
|
57 |
-
|
58 |
-
After downloading, ensure the file is named exactly "best_swin_upernet_main.pth" and saved in the same directory as `main.py` and `model.py`.
|
59 |
-
|
60 |
-
This weight file contains the Swin-Tiny UPerNet model trained on the ISIC 2018 skin lesion segmentation dataset.
|
61 |
-
|
62 |
-
|
63 |
-
## Dataset
|
64 |
-
|
65 |
-
This project uses the ISIC 2018 Challenge Dataset for training, which contains dermoscopic images of skin lesions annotated for binary segmentation.
|
66 |
-
|
67 |
-
Dataset access: https://challenge.isic-archive.com/data/
|
68 |
-
|
69 |
-
## Docker Support
|
70 |
-
|
71 |
-
This project includes a `Dockerfile` for containerized deployment. Run the API with Docker:
|
72 |
-
|
73 |
-
### Build the Docker image
|
74 |
-
```bash
|
75 |
-
docker build -t medical-segmentation-api .
|
76 |
-
```
|
77 |
-
|
78 |
-
### Run the container
|
79 |
-
```bash
|
80 |
-
docker run -p 8000:8000 medical-segmentation-api
|
81 |
-
```
|
82 |
-
|
83 |
-
|
84 |
-
The API will then be available at:
|
85 |
-
http://localhost:8000/predict/
|
86 |
-
|
87 |
-
## Author
|
88 |
-
|
89 |
-
Samyak Shrestha
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|