kadireks commited on
Commit
bd50bfb
·
verified ·
1 Parent(s): 5d4f746

Upload hf_README.md

Browse files
Files changed (1) hide show
  1. hf_README.md +179 -0
hf_README.md ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: ultralytics
3
+ pipeline_tag: object-detection
4
+ tags:
5
+ - yolo11
6
+ - car-damage
7
+ - instance-segmentation
8
+ - vehicle-inspection
9
+ - gradio
10
+ - 24-679
11
+ license: other
12
+ license_name: research-use-only
13
+ ---
14
+
15
+ # PanelPilot
16
+
17
+ *Every dent, on the right panel.*
18
+
19
+ A car damage inspection tool built for CMU 24-679 (Design and Prototyping with AI), Fall 2026.
20
+
21
+ Most damage detectors tell you *that* a car is damaged. PanelPilot tells you **which body
22
+ panel** each piece of damage sits on — which is what a rental company actually needs on a
23
+ handover form. Two models plus a geometric matcher, behind a review interface where a human
24
+ corrects whatever the model got wrong.
25
+
26
+ This repo holds everything: the weights, the engine, and the notebook that runs the GUI.
27
+
28
+ ## Contents
29
+
30
+ | file | what it is |
31
+ |---|---|
32
+ | `Project1_CarDamage_Colab.ipynb` | **start here** — runs the GUI in Colab |
33
+ | `damage_best.pt` | damage detector — YOLO11m, **fine-tuned** |
34
+ | `panel_best.pt` | body-panel segmenter — YOLO11s-seg, **trained from scratch** |
35
+ | `pipeline.py` | loads both models, runs them, matches each damage to a panel |
36
+ | `cardiagram.py` | draws the front/side/rear damage map |
37
+ | `car_views.png` | the hand-drawn car artwork `cardiagram.py` shades |
38
+
39
+ The interface itself lives inside the notebook, not in a `.py` file here, so it can be edited
40
+ and relaunched without re-uploading anything to this repo.
41
+
42
+ ## Quick start
43
+
44
+ 1. Download `Project1_CarDamage_Colab.ipynb` from the Files tab above.
45
+ 2. Open [Colab](https://colab.research.google.com) → **File → Upload notebook** → pick it.
46
+ 3. **Runtime → Change runtime type → T4 GPU** (optional: CPU works, ~10 s per photo instead
47
+ of ~0.3 s).
48
+ 4. Run steps 1 → 6. Nothing to edit — the notebook pulls this repo by name.
49
+
50
+ Step 6 prints a public `*.gradio.live` link, valid about 72 hours.
51
+
52
+ ## Using the interface
53
+
54
+ **Left column — input.** Enter a car or rental ID, pick **pickup** or **return**, add a photo,
55
+ press *Analyze this photo*. The result banner says either `No damage found` with the
56
+ confidence threshold it used, or how many findings there are and how many need a human look.
57
+
58
+ Two shot types:
59
+
60
+ - **Overall shot** — both models run. The panel segmenter finds the bodywork, the damage
61
+ detector finds the damage, and each finding is tied to a panel.
62
+ - **Detail shot** — a close-up where no whole panel is visible. You name the panel; only the
63
+ damage model runs. Use this when an overall shot returns no panels.
64
+
65
+ **Centre — the annotated photo.** Damage boxes numbered to match the findings table. The
66
+ **Panel overlay** control under *Thresholds and display* switches between shaded panels,
67
+ shaded with names, and off. Click any spot on the photo to log damage the model missed.
68
+
69
+ **Right — the damage map.** Front, side and rear views with affected panels shaded. By
70
+ default it shows the current photo only; switch **Map shows** to *All photos* to combine
71
+ several angles of the same car into one map.
72
+
73
+ **Findings tab.** Every finding as a row. Highlighted rows need a look — low confidence, no
74
+ panel overlap, or matched by proximity rather than overlap. Select one to fix its damage type
75
+ or panel, or reject it outright. The damage map highlights whichever finding is selected.
76
+
77
+ **Export tab.**
78
+
79
+ - **Generate PDF report** — verdict, damage map, findings table and every annotated photo, one
80
+ document, for handing to a customer or filing with the rental record.
81
+ - **Export data (zip)** — CSV + JSON + damage-map PNG + annotated photos, for analysis.
82
+
83
+ Photos accumulate into one car record until you press **Clear and start a new car**.
84
+
85
+ ## Thresholds worth knowing
86
+
87
+ | control | default | raise it / lower it |
88
+ |---|---|---|
89
+ | Damage confidence | 0.25 | lower to catch faint damage, raise to cut false alarms |
90
+ | Glass / lamp confidence | 0.25 | raise when glare reads as cracked glass |
91
+ | Panel confidence | 0.25 | lower when no panels are found on an awkward angle |
92
+
93
+ ## The two models
94
+
95
+ **Damage detector** — YOLO11m, fine-tuned on CarDD plus a set of clean-car negatives added to
96
+ cut false positives on undamaged bodywork. Six classes:
97
+
98
+ ```
99
+ dent · scratch · crack · shattered_glass · broken_lamp · flat_tire
100
+ ```
101
+
102
+ **Panel segmenter** — YOLO11s-seg, trained from scratch (not fine-tuned) on a
103
+ human-in-the-loop car-parts set, with rotation and multi-scale augmentation. 21 panel classes,
104
+ instance segmentation so each panel comes back as a mask rather than a box.
105
+
106
+ Two different training strategies on purpose: the course requires at least two of
107
+ {trained-from-scratch, fine-tuned, off-the-shelf}, and two fine-tunes would only count once.
108
+
109
+ ## How damage gets assigned to a panel
110
+
111
+ For each damage box, `pipeline.py` measures how much of the box overlaps each panel mask.
112
+
113
+ 1. **Overlap ≥ 5%** → assigned to the panel with the largest overlap. Any other panel above
114
+ 20% is recorded in `also_touches`, so damage straddling a seam isn't silently simplified.
115
+ 2. **No overlap** → assigned to the nearest panel, if it is within 5% of the image diagonal.
116
+ 3. **Otherwise** → `unassigned`, and flagged for a human.
117
+
118
+ Every finding carries *how* it was matched, so a reviewer can see which calls to trust.
119
+ Thresholds live in `pipeline.Settings`.
120
+
121
+ ## Using the engine without the GUI
122
+
123
+ ```python
124
+ from huggingface_hub import snapshot_download
125
+ import sys
126
+
127
+ ENGINE = snapshot_download("kadireks/car-damage-review")
128
+ sys.path.insert(0, ENGINE)
129
+
130
+ import pipeline
131
+ pipe = pipeline.Pipeline(f"{ENGINE}/damage_best.pt", f"{ENGINE}/panel_best.pt")
132
+
133
+ img, panels, df = pipe.analyze("car.jpg") # df: one row per finding
134
+ vis = pipe.draw(img, panels, df) # annotated image (BGR)
135
+ ```
136
+
137
+ `df` columns:
138
+
139
+ ```
140
+ damage · damage_conf · panel · panel_overlap · also_touches · match · x1 · y1 · x2 · y2
141
+ ```
142
+
143
+ `match` is `overlap`, `nearest (Npx)`, `no panel within 5% of image diagonal`, or `reviewer`
144
+ once a human has corrected it.
145
+
146
+ ## Known limitations
147
+
148
+ - **No end-to-end accuracy figure yet.** The two models have their own training metrics, but
149
+ the combined damage→panel pipeline has not been scored against a held-out set. The review
150
+ interface logs every human correction, which is the intended source for that evaluation.
151
+ - **"No damage found" is threshold-dependent.** A clean result at `damage_conf = 0.25` is not
152
+ proof a car is undamaged. Lower the threshold to check.
153
+ - **Glare and reflections** can read as `scratch` or `shattered_glass`. A separate, higher
154
+ threshold for glass and lamp classes exists for this reason.
155
+ - **Angle matters.** The panel segmenter is strongest on three-quarter and straight-on views;
156
+ extreme angles and tight crops often produce no panels at all. That is what detail-shot mode
157
+ is for.
158
+ - **Speed**: roughly 0.3 s per photo on a T4, 10–12 s on CPU.
159
+
160
+ ## If the result images come up blank
161
+
162
+ Some Colab runtimes will not serve generated image files back to the browser. Set
163
+ `USE_DATA_URI = True` in step 3 of the notebook and re-run steps 3, 5 and 6. The pictures are
164
+ then embedded directly in the page instead of being fetched. Click-to-add-missed-damage turns
165
+ off in that mode; everything else, PDF included, still works.
166
+
167
+ ## Data and licence
168
+
169
+ The damage detector was fine-tuned on **CarDD**, which is licensed for research use and may
170
+ not be redistributed. The trained weights are published here; **the dataset images are not**,
171
+ and none are included in this repo. If you intend to use these weights for anything beyond
172
+ research or coursework, check CarDD's terms first.
173
+
174
+ The panel segmenter's training images were collected and labelled by the project team.
175
+
176
+ ## Credits
177
+
178
+ Built by Krit and Shane for CMU 24-679, Fall 2026. Models trained with
179
+ [Ultralytics](https://github.com/ultralytics/ultralytics) YOLO11.