Wizzas commited on
Commit
98fbcd9
路
verified 路
1 Parent(s): 9a9309b

Upload source code

Browse files
Files changed (1) hide show
  1. README.md +26 -28
README.md CHANGED
@@ -8,8 +8,8 @@ tags:
8
 
9
  <div align="center">
10
  <picture>
11
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/hero-dark.svg" />
12
- <img src="docs/assets/hero-light.svg" alt="DefectRAG: visual evidence, grounded answers" width="100%" />
13
  </picture>
14
 
15
  <p><strong>Industrial visual inspection with a fine-tuned vision model and an evidence-grounded assistant.</strong><br/>
@@ -36,20 +36,18 @@ tags:
36
  <img src="https://img.shields.io/badge/MFA-native_TOTP-635BFF?style=flat-square" alt="Native Supabase TOTP MFA" />
37
  <img src="https://img.shields.io/badge/n8n-case_emails_live-EA4B71?style=flat-square&amp;logo=n8n&amp;logoColor=white" alt="n8n on AWS delivers Corrective Action emails" />
38
  <img src="https://img.shields.io/badge/License-MIT-7963DF?style=flat-square" alt="MIT application licence" />
39
- <a href="https://github.com/WAYTECHG/DefectRAG/actions/workflows/ci.yml"><img src="https://github.com/WAYTECHG/DefectRAG/actions/workflows/ci.yml/badge.svg" alt="CI: tests and builds on every push" /></a>
40
- <a href="https://github.com/WAYTECHG/DefectRAG/actions/workflows/release.yml"><img src="https://github.com/WAYTECHG/DefectRAG/actions/workflows/release.yml/badge.svg" alt="Release: one-click dashboard deployment to Hugging Face" /></a>
41
 
42
- <p><a href="https://huggingface.co/spaces/Wizzas/DefectRAG">Live demo</a> 路 <a href="https://defectrag.duckdns.org">AWS-hosted showcase</a> 路 <a href="#features">Features</a> 路 <a href="#results">Results</a> 路 <a href="#how-it-works">How it works</a> 路 <a href="#quick-start">Quick start</a> 路 <a href="#documentation">Docs</a> 路 <a href="docs/STAFF_QUICK_GUIDE.md">Staff guide</a></p>
43
  </div>
44
 
45
  <p align="center">
46
  <picture>
47
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/screenshots/result-compare-dark.png" />
48
- <img src="docs/assets/screenshots/result-compare.png" alt="Inspection result: the original photo beside the highlighted unusual areas, with the difference score and the review limit" width="49%" />
49
  </picture>
50
  <picture>
51
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/screenshots/overview-dark.png" />
52
- <img src="docs/assets/screenshots/overview-light.png" alt="The dashboard overview: inspection steps, result counts and inspections over time" width="49%" />
53
  </picture>
54
  </p>
55
 
@@ -108,12 +106,12 @@ the threshold.
108
  The coreset is the main gain and it also holds on a second dataset. The fine-tune adds a small gain that is clear on
109
  Macaroni 1, Macaroni 2 and PCB 1. Rotated training views, a second backbone, global and position-aware distances, score
110
  fusions and a simpler fine-tune were also tested and did not help; all of it is documented in
111
- [the experiments](docs/ENCODER_DIAGNOSTIC.md).
112
 
113
  ### Generalisation check on MVTec AD
114
 
115
  The three detector variants were scored **once** on MVTec AD (15 other products, 1,725 test images), with the protocol
116
- written before any score existed ([protocol and results](docs/MVTEC_EVALUATION.md)). The vision model was never trained
117
  on MVTec.
118
 
119
  | MVTec AD, mean over 15 products | Random-sample memory | Coreset memory | Coreset + VisA fine-tuned encoder |
@@ -172,7 +170,7 @@ quoted sentence is the expected one. The same Qwen2.5-3B was measured before and
172
  The "before" scores differ between rows because the runtime differs, not the model: Ollama forces the answer into the
173
  expected JSON shape, which the plain test server does not. Compare along a row, not down a column.
174
 
175
- Details, a second question set and caveats: [language-model card](docs/model-cards/QWEN_MODEL_CARD.md).
176
 
177
  ### Limitations
178
 
@@ -199,19 +197,19 @@ Details, a second question set and caveats: [language-model card](docs/model-car
199
 
200
  <p align="center">
201
  <picture>
202
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/diagrams/architecture-dark.svg" />
203
- <img src="docs/assets/diagrams/architecture-light.svg" alt="System architecture: the React dashboard calls a Hugging Face Space (Gradio + FastAPI) that queues ZeroGPU jobs for the DINOv2 vision pipeline and the LangGraph evidence assistant; Supabase holds auth, storage and Postgres with row-level security; an event queue, Edge Function and n8n on AWS send case emails through Resend; GitHub Actions and AWS monitoring cover delivery and operations." width="100%" />
204
  </picture>
205
  </p>
206
 
207
  <p align="center">
208
  <picture>
209
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/diagrams/pipelines-dark.svg" />
210
- <img src="docs/assets/diagrams/pipelines-light.svg" alt="Request pipelines. A photo is resized to a 448 px short edge, encoded by fine-tuned DINOv2, masked to the foreground and compared with 32,768 normal patches to give a heatmap, score and verdict. A question about the saved measurement reads stored facts; any other question runs the LangGraph nodes route, retrieve, validate_evidence, generate and validate_answer, ending in a cited answer or an abstention." width="100%" />
211
  </picture>
212
  </p>
213
 
214
- <sub>Diagrams are generated from <a href="docs/assets/diagrams/build_diagrams.py"><code>docs/assets/diagrams/build_diagrams.py</code></a>; edit that file and rerun it to change them.</sub>
215
 
216
  <details>
217
  <summary><strong>Accounts, approval and email automation</strong></summary>
@@ -235,7 +233,7 @@ flowchart TD
235
  ```
236
 
237
  Access rules, MFA and case ownership are enforced below the frontend. Saving a case never depends on email: if delivery
238
- fails, the case stays saved and the event waits in the queue. See [Security](docs/SECURITY.md).
239
  </details>
240
 
241
  ## Tech stack
@@ -269,7 +267,7 @@ py -3.11 -m venv .venv
269
  ```
270
 
271
  Then open http://127.0.0.1:8767. A GPU is optional. For local explanations install [Ollama](https://ollama.com) with
272
- `qwen2.5:3b`. Sign-in, the team workspace and emails need your own Supabase and email setup ([Setup](docs/SETUP.md)).
273
  This recipe was not re-tested on a completely fresh machine.
274
 
275
  **Development checks:**
@@ -298,13 +296,13 @@ results/ Published evaluation summaries
298
 
299
  | Document | Contents |
300
  |---|---|
301
- | [Detector model card](docs/model-cards/DETECTOR_MODEL_CARD.md) | What the vision model is, how it was trained, per-product results, limits |
302
- | [Language model card](docs/model-cards/QWEN_MODEL_CARD.md) | The fine-tuned Qwen: method, data, evaluation, known failures, licence |
303
- | [Detector experiments](docs/ENCODER_DIAGNOSTIC.md) | Every variant tried, including the ones that did not help |
304
- | [MVTec AD check](docs/MVTEC_EVALUATION.md) | The pre-written protocol and the one-run results |
305
- | [Qwen fine-tuning](docs/QWEN_FINETUNING_RESULTS.md) | Full tables and how to repeat the training |
306
- | [Setup](docs/SETUP.md) 路 [Security](docs/SECURITY.md) 路 [Operations](docs/OPERATIONS.md) 路 [Architecture](docs/ARCHITECTURE.md) | Running, securing and maintaining the system |
307
- | [Staff guide](docs/STAFF_QUICK_GUIDE.md) | How staff use the dashboard |
308
 
309
  ## Validation
310
 
@@ -324,8 +322,8 @@ results/ Published evaluation summaries
324
 
325
  ## Credits and licences
326
 
327
- Application code: [MIT](LICENSE). Models and datasets keep their own licences; see the
328
- [third-party notices](docs/THIRD_PARTY_NOTICES.md).
329
 
330
  - [VisA](https://github.com/amazon-science/spot-diff), Zou et al., ECCV 2022: CC BY 4.0.
331
  - [MVTec AD](https://www.mvtec.com/company/research/datasets/mvtec-ad), Bergmann et al., CVPR 2019 / IJCV 2021: CC BY-NC-SA 4.0, used only for one evaluation.
 
8
 
9
  <div align="center">
10
  <picture>
11
+ <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/hero-dark.svg" />
12
+ <img src="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/hero-light.svg" alt="DefectRAG: visual evidence, grounded answers" width="100%" />
13
  </picture>
14
 
15
  <p><strong>Industrial visual inspection with a fine-tuned vision model and an evidence-grounded assistant.</strong><br/>
 
36
  <img src="https://img.shields.io/badge/MFA-native_TOTP-635BFF?style=flat-square" alt="Native Supabase TOTP MFA" />
37
  <img src="https://img.shields.io/badge/n8n-case_emails_live-EA4B71?style=flat-square&amp;logo=n8n&amp;logoColor=white" alt="n8n on AWS delivers Corrective Action emails" />
38
  <img src="https://img.shields.io/badge/License-MIT-7963DF?style=flat-square" alt="MIT application licence" />
 
 
39
 
40
+ <p><a href="https://huggingface.co/spaces/Wizzas/DefectRAG">Live demo</a> 路 <a href="https://defectrag.duckdns.org">AWS-hosted showcase</a> 路 <a href="#features">Features</a> 路 <a href="#results">Results</a> 路 <a href="#how-it-works">How it works</a> 路 <a href="#quick-start">Quick start</a> 路 <a href="#documentation">Docs</a> 路 <a href="https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/STAFF_QUICK_GUIDE.md">Staff guide</a></p>
41
  </div>
42
 
43
  <p align="center">
44
  <picture>
45
+ <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/screenshots/result-compare-dark.png" />
46
+ <img src="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/screenshots/result-compare.png" alt="Inspection result: the original photo beside the highlighted unusual areas, with the difference score and the review limit" width="49%" />
47
  </picture>
48
  <picture>
49
+ <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/screenshots/overview-dark.png" />
50
+ <img src="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/screenshots/overview-light.png" alt="The dashboard overview: inspection steps, result counts and inspections over time" width="49%" />
51
  </picture>
52
  </p>
53
 
 
106
  The coreset is the main gain and it also holds on a second dataset. The fine-tune adds a small gain that is clear on
107
  Macaroni 1, Macaroni 2 and PCB 1. Rotated training views, a second backbone, global and position-aware distances, score
108
  fusions and a simpler fine-tune were also tested and did not help; all of it is documented in
109
+ [the experiments](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/ENCODER_DIAGNOSTIC.md).
110
 
111
  ### Generalisation check on MVTec AD
112
 
113
  The three detector variants were scored **once** on MVTec AD (15 other products, 1,725 test images), with the protocol
114
+ written before any score existed ([protocol and results](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/MVTEC_EVALUATION.md)). The vision model was never trained
115
  on MVTec.
116
 
117
  | MVTec AD, mean over 15 products | Random-sample memory | Coreset memory | Coreset + VisA fine-tuned encoder |
 
170
  The "before" scores differ between rows because the runtime differs, not the model: Ollama forces the answer into the
171
  expected JSON shape, which the plain test server does not. Compare along a row, not down a column.
172
 
173
+ Details, a second question set and caveats: [language-model card](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/model-cards/QWEN_MODEL_CARD.md).
174
 
175
  ### Limitations
176
 
 
197
 
198
  <p align="center">
199
  <picture>
200
+ <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/diagrams/architecture-dark.svg" />
201
+ <img src="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/diagrams/architecture-light.svg" alt="System architecture: the React dashboard calls a Hugging Face Space (Gradio + FastAPI) that queues ZeroGPU jobs for the DINOv2 vision pipeline and the LangGraph evidence assistant; Supabase holds auth, storage and Postgres with row-level security; an event queue, Edge Function and n8n on AWS send case emails through Resend; GitHub Actions and AWS monitoring cover delivery and operations." width="100%" />
202
  </picture>
203
  </p>
204
 
205
  <p align="center">
206
  <picture>
207
+ <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/diagrams/pipelines-dark.svg" />
208
+ <img src="https://huggingface.co/Wizzas/DefectRAG/resolve/main/docs/assets/diagrams/pipelines-light.svg" alt="Request pipelines. A photo is resized to a 448 px short edge, encoded by fine-tuned DINOv2, masked to the foreground and compared with 32,768 normal patches to give a heatmap, score and verdict. A question about the saved measurement reads stored facts; any other question runs the LangGraph nodes route, retrieve, validate_evidence, generate and validate_answer, ending in a cited answer or an abstention." width="100%" />
209
  </picture>
210
  </p>
211
 
212
+ <sub>Diagrams are generated from <a href="https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/assets/diagrams/build_diagrams.py"><code>docs/assets/diagrams/build_diagrams.py</code></a>; edit that file and rerun it to change them.</sub>
213
 
214
  <details>
215
  <summary><strong>Accounts, approval and email automation</strong></summary>
 
233
  ```
234
 
235
  Access rules, MFA and case ownership are enforced below the frontend. Saving a case never depends on email: if delivery
236
+ fails, the case stays saved and the event waits in the queue. See [Security](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/SECURITY.md).
237
  </details>
238
 
239
  ## Tech stack
 
267
  ```
268
 
269
  Then open http://127.0.0.1:8767. A GPU is optional. For local explanations install [Ollama](https://ollama.com) with
270
+ `qwen2.5:3b`. Sign-in, the team workspace and emails need your own Supabase and email setup ([Setup](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/SETUP.md)).
271
  This recipe was not re-tested on a completely fresh machine.
272
 
273
  **Development checks:**
 
296
 
297
  | Document | Contents |
298
  |---|---|
299
+ | [Detector model card](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/model-cards/DETECTOR_MODEL_CARD.md) | What the vision model is, how it was trained, per-product results, limits |
300
+ | [Language model card](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/model-cards/QWEN_MODEL_CARD.md) | The fine-tuned Qwen: method, data, evaluation, known failures, licence |
301
+ | [Detector experiments](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/ENCODER_DIAGNOSTIC.md) | Every variant tried, including the ones that did not help |
302
+ | [MVTec AD check](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/MVTEC_EVALUATION.md) | The pre-written protocol and the one-run results |
303
+ | [Qwen fine-tuning](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/QWEN_FINETUNING_RESULTS.md) | Full tables and how to repeat the training |
304
+ | [Setup](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/SETUP.md) 路 [Security](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/SECURITY.md) 路 [Operations](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/OPERATIONS.md) 路 [Architecture](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/ARCHITECTURE.md) | Running, securing and maintaining the system |
305
+ | [Staff guide](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/STAFF_QUICK_GUIDE.md) | How staff use the dashboard |
306
 
307
  ## Validation
308
 
 
322
 
323
  ## Credits and licences
324
 
325
+ Application code: [MIT](https://huggingface.co/Wizzas/DefectRAG/blob/main/LICENSE). Models and datasets keep their own licences; see the
326
+ [third-party notices](https://huggingface.co/Wizzas/DefectRAG/blob/main/docs/THIRD_PARTY_NOTICES.md).
327
 
328
  - [VisA](https://github.com/amazon-science/spot-diff), Zou et al., ECCV 2022: CC BY 4.0.
329
  - [MVTec AD](https://www.mvtec.com/company/research/datasets/mvtec-ad), Bergmann et al., CVPR 2019 / IJCV 2021: CC BY-NC-SA 4.0, used only for one evaluation.