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