File size: 2,895 Bytes
4e002c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761ffd2
 
4e002c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
license: apache-2.0
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- graphic
- 2d
- 3d
- image-classifier
- art
---
 
![1.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/aTXiSUlPQ_2utT9X2ERpN.png)

# **Graphic-Class**

> **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.

---

## **Label Space: 2 Classes**

The model classifies each image into one of the following categories:

```
0: bad
1: good
```

* `bad`: images with bad symbols, inappropriate or offensive text, broken UI/UX elements, distorted or harmful designs.
* `good`: plain, safe, or character-rich graphics, such as 2D game elements, educational visuals, or well-structured UI components.

---

## **Install Dependencies**

```bash
pip install -q transformers torch pillow gradio
```

---

## **Inference Code**

```python
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "prithivMLmods/Graphic-Class"  # Replace with your model path if different
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# Label mapping
id2label = {
    "0": "bad",
    "1": "good"
}

def classify_graphic(image):
    image = Image.fromarray(image).convert("RGB")
    inputs = processor(images=image, return_tensors="pt")

    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

    prediction = {
        id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
    }

    return prediction

# Gradio Interface
iface = gr.Interface(
    fn=classify_graphic,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(num_top_classes=2, label="Graphic Content Classification"),
    title="Graphic-Class",
    description="Upload a graphic or design asset to classify it as 'good' or 'bad'."
)

if __name__ == "__main__":
    iface.launch()
```

---

## **Intended Use**

**Graphic-Class** can be used for:

* **Graphic Content Moderation** – Automatically filter unsafe or visually inappropriate designs in creative pipelines.
* **Game Asset Filtering** – Evaluate textures, objects, or sprites for suitability in game environments.
* **UI/UX Quality Control** – Detect broken or low-quality interface components in design feedback loops.
* **Educational & Kids App Filtering** – Ensure graphics meet safety and design standards for children's content.