Update README.md
Browse files
README.md
CHANGED
@@ -2,8 +2,22 @@
|
|
2 |
license: apache-2.0
|
3 |
datasets:
|
4 |
- cmudrc/3d-printed-or-not
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
```py
|
9 |
Classification Report:
|
@@ -19,3 +33,82 @@ Not 3D Printed 0.9368 0.9081 0.9222 25760
|
|
19 |
|
20 |

|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
license: apache-2.0
|
3 |
datasets:
|
4 |
- cmudrc/3d-printed-or-not
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
base_model:
|
8 |
+
- google/siglip2-base-patch16-224
|
9 |
+
pipeline_tag: image-classification
|
10 |
+
library_name: transformers
|
11 |
+
tags:
|
12 |
+
- 3D-Printed-Or-Not
|
13 |
+
- SigLIP2
|
14 |
---
|
15 |
|
16 |
+

|
17 |
+
|
18 |
+
# **3D-Printed-Or-Not-SigLIP2**
|
19 |
+
|
20 |
+
> **3D-Printed-Or-Not-SigLIP2** is a vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for **binary image classification**. It is trained to distinguish between images of **3D printed** and **non-3D printed** objects using the **SiglipForImageClassification** architecture.
|
21 |
|
22 |
```py
|
23 |
Classification Report:
|
|
|
33 |
|
34 |

|
35 |
|
36 |
+
|
37 |
+
---
|
38 |
+
|
39 |
+
## **Label Space: 2 Classes**
|
40 |
+
|
41 |
+
The model classifies each image into one of the following categories:
|
42 |
+
|
43 |
+
```
|
44 |
+
Class 0: "3D Printed"
|
45 |
+
Class 1: "Not 3D Printed"
|
46 |
+
```
|
47 |
+
|
48 |
+
---
|
49 |
+
|
50 |
+
## **Install Dependencies**
|
51 |
+
|
52 |
+
```bash
|
53 |
+
pip install -q transformers torch pillow gradio
|
54 |
+
```
|
55 |
+
|
56 |
+
---
|
57 |
+
|
58 |
+
## **Inference Code**
|
59 |
+
|
60 |
+
```python
|
61 |
+
import gradio as gr
|
62 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
63 |
+
from PIL import Image
|
64 |
+
import torch
|
65 |
+
|
66 |
+
# Load model and processor
|
67 |
+
model_name = "prithivMLmods/3D-Printed-Or-Not-SigLIP2" # Replace with your model path if different
|
68 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
69 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
70 |
+
|
71 |
+
# Label mapping
|
72 |
+
id2label = {
|
73 |
+
"0": "3D Printed",
|
74 |
+
"1": "Not 3D Printed"
|
75 |
+
}
|
76 |
+
|
77 |
+
def classify_3d_printed(image):
|
78 |
+
image = Image.fromarray(image).convert("RGB")
|
79 |
+
inputs = processor(images=image, return_tensors="pt")
|
80 |
+
|
81 |
+
with torch.no_grad():
|
82 |
+
outputs = model(**inputs)
|
83 |
+
logits = outputs.logits
|
84 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
85 |
+
|
86 |
+
prediction = {
|
87 |
+
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
|
88 |
+
}
|
89 |
+
|
90 |
+
return prediction
|
91 |
+
|
92 |
+
# Gradio Interface
|
93 |
+
iface = gr.Interface(
|
94 |
+
fn=classify_3d_printed,
|
95 |
+
inputs=gr.Image(type="numpy"),
|
96 |
+
outputs=gr.Label(num_top_classes=2, label="3D Printing Classification"),
|
97 |
+
title="3D-Printed-Or-Not-SigLIP2",
|
98 |
+
description="Upload an image to detect if the object is 3D printed or not."
|
99 |
+
)
|
100 |
+
|
101 |
+
if __name__ == "__main__":
|
102 |
+
iface.launch()
|
103 |
+
```
|
104 |
+
|
105 |
+
---
|
106 |
+
|
107 |
+
## **Intended Use**
|
108 |
+
|
109 |
+
**3D-Printed-Or-Not-SigLIP2** can be used for:
|
110 |
+
|
111 |
+
- **Manufacturing Verification** – Classify objects to ensure they meet production standards.
|
112 |
+
- **Educational Tools** – Train models and learners to distinguish between manufacturing methods.
|
113 |
+
- **Retail Filtering** – Categorize product images by manufacturing technique.
|
114 |
+
- **Quality Control** – Spot check datasets or content for 3D printing.
|