Views
No views yet

Anime-Classification-v1.0 is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for a single-label classification task. It is designed to classify anime-related images using the SiglipForImageClassification architecture.
1Classification Report:
2 precision recall f1-score support
3
4 3D 0.7979 0.8443 0.8204 4649
5 Bangumi 0.8677 0.8728 0.8702 4914
6 Comic 0.9716 0.9233 0.9468 5746
7Illustration 0.8204 0.8186 0.8195 6064
8
9 accuracy 0.8648 21373
10 macro avg 0.8644 0.8647 0.8642 21373
11weighted avg 0.8670 0.8648 0.8656 21373
Class 0: "3D"
Class 1: "Bangumi"
Class 2: "Comic"
Class 3: "Illustration"!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/Anime-Classification-v1.0" # New model name
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11def classify_anime_image(image):
12 """Predicts the anime category for an input image."""
13 image = Image.fromarray(image).convert("RGB")
14 inputs = processor(images=image, return_tensors="pt")
15
16 with torch.no_grad():
17 outputs = model(**inputs)
18 logits = outputs.logits
19 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
20
21 labels = {
22 "0": "3D", "1": "Bangumi", "2": "Comic", "3": "Illustration"
23 }
24 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
25
26 return predictions
27
28# Create Gradio interface
29iface = gr.Interface(
30 fn=classify_anime_image,
31 inputs=gr.Image(type="numpy"),
32 outputs=gr.Label(label="Prediction Scores"),
33 title="Anime Classification v1.0",
34 description="Upload an image to classify the anime style category."
35)
36
37if __name__ == "__main__":
38 iface.launch()