Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# EL Defect Detection — Training Package
|
| 2 |
+
|
| 3 |
+
Train a **U-Net++ with EfficientNet-B4 encoder** for solar cell EL defect segmentation.
|
| 4 |
+
|
| 5 |
+
## Quick Start (RTX 4060 / any CUDA GPU)
|
| 6 |
+
|
| 7 |
+
```bash
|
| 8 |
+
# 1. Clone this repo
|
| 9 |
+
git clone https://huggingface.co/nithishbasireddy/el-defect-training
|
| 10 |
+
cd el-defect-training
|
| 11 |
+
|
| 12 |
+
# 2. Install dependencies
|
| 13 |
+
pip install -r requirements.txt
|
| 14 |
+
|
| 15 |
+
# 3. Verify setup
|
| 16 |
+
python test_setup.py
|
| 17 |
+
|
| 18 |
+
# 4. Train (auto-downloads E-SCDD dataset)
|
| 19 |
+
python train.py
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
Training takes ~2-3 hours on RTX 4060. Model saves to `output/best_model.pth`.
|
| 23 |
+
|
| 24 |
+
## After Training
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
# Run the Streamlit app with your trained model
|
| 28 |
+
streamlit run app.py
|
| 29 |
+
# → Set model path to "output/best_model.pth" in sidebar
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Architecture
|
| 33 |
+
|
| 34 |
+
- **Model**: U-Net++ + EfficientNet-B4 + scSE attention (20.9M params)
|
| 35 |
+
- **Dataset**: E-SCDD (903 images, 512×512, 30→5 class remap)
|
| 36 |
+
- **Loss**: 0.5 × Dice + 0.5 × Focal (γ=2.0) — handles severe class imbalance
|
| 37 |
+
- **Optimizer**: AdamW with differential LR (encoder 1e-4, decoder 5e-4)
|
| 38 |
+
- **AMP**: Mixed precision for 8GB VRAM GPUs
|
| 39 |
+
|
| 40 |
+
## Classes (5)
|
| 41 |
+
|
| 42 |
+
| ID | Name | E-SCDD Labels | Color |
|
| 43 |
+
|----|------|---------------|-------|
|
| 44 |
+
| 0 | background | 0-8, 21-24, 29 | Black |
|
| 45 |
+
| 1 | busbar | 9 | Green |
|
| 46 |
+
| 2 | crack | 10, 14 | Blue |
|
| 47 |
+
| 3 | dark/inactive | 11, 17, 20 | Red |
|
| 48 |
+
| 4 | other_defect | 12,13,15,16,18,19,25-28 | Yellow |
|
| 49 |
+
|
| 50 |
+
## Why U-Net++ over U-Net?
|
| 51 |
+
|
| 52 |
+
U-Net++ has **dense skip connections** between encoder and decoder. For thin structures like cracks (often <10px wide), these nested connections preserve fine details that plain U-Net's single skip connections lose. Validated in medical imaging (thin vessels) and industrial inspection.
|