# car-damage-morocco
End-to-end car damage assessment for the Moroccan market. Photo → car model → damaged parts → cost estimate in MAD → French-language report.
📖 **Full documentation → car-damage-morocco.readthedocs.io**
See ARCHITECTURE.md for the system design.
## Quick start
```bash
python -m venv .venv && .venv\Scripts\activate # Windows
# python -m venv .venv && source .venv/bin/activate # macOS / Linux
pip install -r requirements.txt
```
### Drop trained weights in place
After training each stage on Kaggle, download the weights and copy them here:
| Stage | Source file (on Kaggle) | Place here |
|---|---|---|
| 0 | `/kaggle/working/car_classifier_efficientnet_b0.keras` | `models/stage0/best.keras` |
| 1 | `/kaggle/working/stage1_deliverables/parts_seg_best.pt` | `models/stage1/best.pt` |
| 2 | `/kaggle/working/damage_segmenter_yolov8s.pt` | `models/stage2/best.pt` |
### Run the Streamlit demo
```bash
streamlit run app/streamlit_app.py
```
Upload an image, watch detections, get a French report with MAD pricing.
### Programmatic use
```python
import cv2
from car_damage_morocco import DamageDetector
from car_damage_morocco.detector import default_detector
detector = default_detector() # reads from models/ + data/
result = detector.predict(cv2.imread("car.jpg"), render=True)
print(result.car_display, result.car_confidence)
print(result.total_MAD, "MAD")
print(result.report_fr)
for f in result.findings:
print(f.part, f.damage_type, f.cost_MAD)
```
## Tests
```bash
python -m pytest tests -v
```
Smoke tests run without weights — they validate CSV/JSON alignment, fusion math, and French templates.
## Training notebooks
Three Kaggle notebooks (T4 GPU). Pre-rendered HTML views are linked below if GitHub's notebook renderer struggles with them.
| Stage | Model | Dataset | View |
|---|---|---|---|
| `stage0_car_classifier.ipynb` | EfficientNetB0 | 20 Moroccan-market models | HTML · Colab |
| `stage1_parts_seg_train.ip …