gfichetdc commited on
Commit
0959301
·
1 Parent(s): 3c505d2

Initial Gradio space

Browse files
Files changed (3) hide show
  1. README.md +39 -8
  2. app.py +19 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,14 +1,45 @@
1
  ---
2
- title: Casting Defect Vit
3
- emoji: 🚀
4
- colorFrom: pink
5
- colorTo: green
6
  sdk: gradio
7
- sdk_version: 6.19.0
8
- python_version: '3.13'
9
  app_file: app.py
10
  pinned: false
11
- license: cc
 
 
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Casting Defect Detection
3
+ emoji: 🔍
4
+ colorFrom: green
5
+ colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 5.33.0
 
8
  app_file: app.py
9
  pinned: false
10
+ license: mit
11
+ models:
12
+ - gfichetdc/casting-defect-vit
13
  ---
14
 
15
+ # Casting Defect Detection (ViT)
16
+
17
+ Fine-tuned **ViT-B/16** on 6,633 casting surface images to classify parts as **defective** or **ok**.
18
+
19
+ | Metric | Value |
20
+ |--------|-------|
21
+ | Macro F1 | 0.995 |
22
+ | Accuracy | 99.6% |
23
+ | Base model | google/vit-base-patch16-224 |
24
+ | Training images | 6,633 |
25
+ | Test images | 715 |
26
+ | Epochs | 3 |
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ from transformers import pipeline
32
+
33
+ classifier = pipeline("image-classification", model="gfichetdc/casting-defect-vit")
34
+ result = classifier("path/to/casting_image.jpeg")
35
+ ```
36
+
37
+ ## Dataset
38
+
39
+ [Kaggle — Casting Product Image Data for Quality Inspection](https://www.kaggle.com/datasets/ravirajsinh45/real-life-industrial-dataset-of-casting-product): 7,348 grayscale images of submersible pump impellers.
40
+
41
+ ## Training
42
+
43
+ - Fine-tuned `google/vit-base-patch16-224` with HuggingFace Trainer
44
+ - lr=2e-5, batch size 16, 3 epochs on RTX 3060 (~10 min)
45
+ - Experiment tracking with MLflow
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline("image-classification", model="gfichetdc/casting-defect-vit")
5
+
6
+ def predict(image):
7
+ results = classifier(image)
8
+ return {r["label"]: r["score"] for r in results}
9
+
10
+ demo = gr.Interface(
11
+ fn=predict,
12
+ inputs=gr.Image(type="pil"),
13
+ outputs=gr.Label(num_top_classes=2),
14
+ title="Casting Defect Detection (ViT)",
15
+ description="Fine-tuned ViT-B/16 classifying casting surface images as defective or ok. 99.5% macro F1.",
16
+ examples=[],
17
+ )
18
+
19
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ Pillow