prithivMLmods commited on
Commit
4e002c1
·
verified ·
1 Parent(s): 0633da2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -3
README.md CHANGED
@@ -1,3 +1,101 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ base_model:
6
+ - google/siglip2-base-patch16-224
7
+ pipeline_tag: image-classification
8
+ library_name: transformers
9
+ tags:
10
+ - graphic
11
+ - 2d
12
+ - 3d
13
+ - image-classifier
14
+ - art
15
+ ---
16
+
17
+ # **Graphic-Class**
18
+
19
+ > **Graphic-Class** is a vision model fine-tuned from **google/siglip2-base-patch16-224** for **graphic content moderation**. It uses the **SiglipForImageClassification** architecture to classify graphical images (such as UI designs, 2D game assets, digital art) into **safe** or **problematic** categories.
20
+
21
+ ---
22
+
23
+ ## **Label Space: 2 Classes**
24
+
25
+ The model classifies each image into one of the following categories:
26
+
27
+ ```
28
+ 0: bad
29
+ 1: good
30
+ ```
31
+
32
+ * `bad`: images with bad symbols, inappropriate or offensive text, broken UI/UX elements, distorted or harmful designs.
33
+ * `good`: plain, safe, or character-rich graphics, such as 2D game elements, educational visuals, or well-structured UI components.
34
+
35
+ ---
36
+
37
+ ## **Install Dependencies**
38
+
39
+ ```bash
40
+ pip install -q transformers torch pillow gradio
41
+ ```
42
+
43
+ ---
44
+
45
+ ## **Inference Code**
46
+
47
+ ```python
48
+ import gradio as gr
49
+ from transformers import AutoImageProcessor, SiglipForImageClassification
50
+ from PIL import Image
51
+ import torch
52
+
53
+ # Load model and processor
54
+ model_name = "prithivMLmods/Graphic-Class" # Replace with your model path if different
55
+ model = SiglipForImageClassification.from_pretrained(model_name)
56
+ processor = AutoImageProcessor.from_pretrained(model_name)
57
+
58
+ # Label mapping
59
+ id2label = {
60
+ "0": "bad",
61
+ "1": "good"
62
+ }
63
+
64
+ def classify_graphic(image):
65
+ image = Image.fromarray(image).convert("RGB")
66
+ inputs = processor(images=image, return_tensors="pt")
67
+
68
+ with torch.no_grad():
69
+ outputs = model(**inputs)
70
+ logits = outputs.logits
71
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
72
+
73
+ prediction = {
74
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
75
+ }
76
+
77
+ return prediction
78
+
79
+ # Gradio Interface
80
+ iface = gr.Interface(
81
+ fn=classify_graphic,
82
+ inputs=gr.Image(type="numpy"),
83
+ outputs=gr.Label(num_top_classes=2, label="Graphic Content Classification"),
84
+ title="Graphic-Class",
85
+ description="Upload a graphic or design asset to classify it as 'good' or 'bad'."
86
+ )
87
+
88
+ if __name__ == "__main__":
89
+ iface.launch()
90
+ ```
91
+
92
+ ---
93
+
94
+ ## **Intended Use**
95
+
96
+ **Graphic-Class** can be used for:
97
+
98
+ * **Graphic Content Moderation** – Automatically filter unsafe or visually inappropriate designs in creative pipelines.
99
+ * **Game Asset Filtering** – Evaluate textures, objects, or sprites for suitability in game environments.
100
+ * **UI/UX Quality Control** – Detect broken or low-quality interface components in design feedback loops.
101
+ * **Educational & Kids App Filtering** – Ensure graphics meet safety and design standards for children's content.