File size: 4,577 Bytes
d4e8c5f
 
 
 
 
 
 
 
 
 
ad15726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d4e8c5f
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: Wound Analysis V2
emoji: 🏒
colorFrom: yellow
colorTo: pink
sdk: gradio
sdk_version: 5.42.0
app_file: app.py
pinned: false
---
# Wound Analysis LE

## 🩹 Project Overview
Wound Analysis LE is an advanced medical imaging tool for automated wound assessment using deep learning. It provides:
- **Wound classification** (type identification)
- **Depth estimation** (3D wound structure)
- **Segmentation** (precise wound area extraction)
- **Severity analysis** (quantitative and AI-powered clinical assessment)

The system is built for research and educational purposes, integrating state-of-the-art computer vision models and a user-friendly Gradio interface.

---

## πŸš€ Features & Workflow
1. **Wound Classification**: Identifies wound type using a vision transformer model.
2. **Depth Estimation**: Generates depth maps and 3D visualizations from 2D images using DepthAnythingV2 (DINOv2 + DPT).
3. **Segmentation**: Extracts wound regions using deep learning models (Deeplabv3+, FCN, SegNet, Unet).
4. **Severity Analysis**: Computes wound area, depth, volume, and provides AI-powered medical assessment (Gemini AI integration).
5. **Interactive Gradio App**: Step-by-step workflow with visualization, overlays, and downloadable results.

---

## πŸ—οΈ Model Architecture
### Segmentation Models
- **Deeplabv3+**: Encoder-decoder with atrous convolutions for semantic segmentation.
- **FCN (VGG16-16s)**: Fully convolutional network for pixel-wise segmentation.
- **SegNet**: Encoder-decoder architecture for efficient segmentation.
- **Unet (multiple variants)**: U-shaped architecture for biomedical image segmentation.

### Depth Estimation
- **DepthAnythingV2**: Combines DINOv2 vision transformer backbone with DPT head for monocular depth prediction.
- **DINOv2**: Self-supervised vision transformer for feature extraction.
- **DPT**: Dense Prediction Transformer for pixel-wise depth estimation.

### Classification
- **Vision Transformer (ViT)**: Used for wound type classification (via HuggingFace Transformers).

---

## πŸ› οΈ Installation & Requirements
1. **Clone the repository**
   ```bash
   git clone <repo-url>
   cd Wound-Analysis-LE
   ```
2. **Install dependencies**
   ```bash
   pip install -r requirements.txt
   ```
   - Key dependencies: `gradio`, `torch`, `tensorflow`, `opencv-python`, `transformers`, `open3d`, `plotly`, `google-generativeai`, etc.
3. **Download model weights**
   - The app will auto-download required weights (e.g., DINOv2, segmentation models) on first run if not present.

---

## πŸ’» Usage Instructions
### Run the Gradio App
```bash
python app.py
```
- Access the app at: [http://localhost:7860](http://localhost:7860)

### Segmentation Tool (Standalone)
```bash
python temp_files/segmentation_app.py
```

### Workflow
1. **Upload a wound image**
2. **Classify**: Get wound type and initial AI analysis
3. **Depth Estimation**: Generate depth map and 3D visualization
4. **Segmentation**: Auto-segment wound area
5. **Severity Analysis**: Quantitative and AI-powered report
6. **Download**: Export masks, overlays, and 3D data

---

## πŸ“Š Training & Evaluation
- **Training scripts**: See `temp_files/train.py`
- **Metrics**: Dice coefficient, precision, recall, loss (see `utils/learning/metrics.py`)
- **Results**: Training history and model checkpoints in `training_history/`
  - Example: Dice coefficient > 0.98 on training set (see `2025-08-07_16-25-27.json`)

---

## πŸ“ Code Structure
- `app.py` β€” Main Gradio app (classification, depth, segmentation, severity)
- `models/` β€” Segmentation model definitions (Deeplab, FCN, SegNet, Unet)
- `depth_anything_v2/` β€” Depth estimation (DINOv2, DPT, utility layers)
- `utils/` β€” Data loading, augmentation, metrics, postprocessing
- `temp_files/` β€” Standalone scripts, experiments, and legacy tools
- `training_history/` β€” Model checkpoints and training logs

---

## πŸ“š References
- [Deeplabv3+ Paper](https://arxiv.org/pdf/1802.02611.pdf)
- [DINOv2 (Meta AI)](https://github.com/facebookresearch/dinov2)
- [DPT: Vision Transformers for Dense Prediction](https://arxiv.org/abs/2103.13413)
- [HuggingFace Transformers](https://huggingface.co/docs/transformers/index)
- [Gradio](https://gradio.app/)
- [Open3D](http://www.open3d.org/)
- [Augmentor](https://github.com/mdbloice/Augmentor)
- Datasets: Custom wound datasets (not included)

---

## ⚠️ Disclaimer
This tool is for research and educational purposes only. It does **not** provide medical advice or diagnosis. Always consult a medical professional for clinical decisions.