prithivMLmods/Graphic-Class
18
1---2license: apache-2.03language:4- en5base_model:6- google/siglip2-base-patch16-2247pipeline_tag: image-classification8library_name: transformers9tags:10- graphic11- 2d12- 3d13- image-classifier14- art15---16 1718 19# **Graphic-Class**20 21> **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.22 23---24 25## **Label Space: 2 Classes**26 27The model classifies each image into one of the following categories:28 29```300: bad311: good32```33 34* `bad`: images with bad symbols, inappropriate or offensive text, broken UI/UX elements, distorted or harmful designs.35* `good`: plain, safe, or character-rich graphics, such as 2D game elements, educational visuals, or well-structured UI components.36 37---38 39## **Install Dependencies**40 41```bash42pip install -q transformers torch pillow gradio43```44 45---46 47## **Inference Code**48 49```python50import gradio as gr51from transformers import AutoImageProcessor, SiglipForImageClassification52from PIL import Image53import torch54 55# Load model and processor56model_name = "prithivMLmods/Graphic-Class" # Replace with your model path if different57model = SiglipForImageClassification.from_pretrained(model_name)58processor = AutoImageProcessor.from_pretrained(model_name)59 60# Label mapping61id2label = {62 "0": "bad",63 "1": "good"64}65 66def classify_graphic(image):67 image = Image.fromarray(image).convert("RGB")68 inputs = processor(images=image, return_tensors="pt")69 70 with torch.no_grad():71 outputs = model(**inputs)72 logits = outputs.logits73 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()74 75 prediction = {76 id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))77 }78 79 return prediction80 81# Gradio Interface82iface = gr.Interface(83 fn=classify_graphic,84 inputs=gr.Image(type="numpy"),85 outputs=gr.Label(num_top_classes=2, label="Graphic Content Classification"),86 title="Graphic-Class",87 description="Upload a graphic or design asset to classify it as 'good' or 'bad'."88)89 90if __name__ == "__main__":91 iface.launch()92```93 94---95 96## **Intended Use**97 98**Graphic-Class** can be used for:99 100* **Graphic Content Moderation** – Automatically filter unsafe or visually inappropriate designs in creative pipelines.101* **Game Asset Filtering** – Evaluate textures, objects, or sprites for suitability in game environments.102* **UI/UX Quality Control** – Detect broken or low-quality interface components in design feedback loops.103* **Educational & Kids App Filtering** – Ensure graphics meet safety and design standards for children's content.