Update README.md
Browse files
README.md
CHANGED
@@ -3,6 +3,11 @@ license: apache-2.0
|
|
3 |
datasets:
|
4 |
- deepghs/anime_classification
|
5 |
---
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
```py
|
8 |
Classification Report:
|
@@ -20,3 +25,77 @@ weighted avg 0.8670 0.8648 0.8656 21373
|
|
20 |
|
21 |

|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
datasets:
|
4 |
- deepghs/anime_classification
|
5 |
---
|
6 |
+

|
7 |
+
|
8 |
+
# **Anime-Classification-v1.0**
|
9 |
+
|
10 |
+
> **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.
|
11 |
|
12 |
```py
|
13 |
Classification Report:
|
|
|
25 |
|
26 |

|
27 |
|
28 |
+
---
|
29 |
+
|
30 |
+
The model categorizes images into 4 anime-related classes:
|
31 |
+
|
32 |
+
```
|
33 |
+
Class 0: "3D"
|
34 |
+
Class 1: "Bangumi"
|
35 |
+
Class 2: "Comic"
|
36 |
+
Class 3: "Illustration"
|
37 |
+
```
|
38 |
+
|
39 |
+
---
|
40 |
+
|
41 |
+
## **Install dependencies**
|
42 |
+
|
43 |
+
```python
|
44 |
+
!pip install -q transformers torch pillow gradio
|
45 |
+
```
|
46 |
+
|
47 |
+
---
|
48 |
+
|
49 |
+
## **Inference Code**
|
50 |
+
|
51 |
+
```python
|
52 |
+
import gradio as gr
|
53 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
54 |
+
from PIL import Image
|
55 |
+
import torch
|
56 |
+
|
57 |
+
# Load model and processor
|
58 |
+
model_name = "prithivMLmods/Anime-Classification-v1.0" # New model name
|
59 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
60 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
61 |
+
|
62 |
+
def classify_anime_image(image):
|
63 |
+
"""Predicts the anime category for an input image."""
|
64 |
+
image = Image.fromarray(image).convert("RGB")
|
65 |
+
inputs = processor(images=image, return_tensors="pt")
|
66 |
+
|
67 |
+
with torch.no_grad():
|
68 |
+
outputs = model(**inputs)
|
69 |
+
logits = outputs.logits
|
70 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
71 |
+
|
72 |
+
labels = {
|
73 |
+
"0": "3D", "1": "Bangumi", "2": "Comic", "3": "Illustration"
|
74 |
+
}
|
75 |
+
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
76 |
+
|
77 |
+
return predictions
|
78 |
+
|
79 |
+
# Create Gradio interface
|
80 |
+
iface = gr.Interface(
|
81 |
+
fn=classify_anime_image,
|
82 |
+
inputs=gr.Image(type="numpy"),
|
83 |
+
outputs=gr.Label(label="Prediction Scores"),
|
84 |
+
title="Anime Classification v1.0",
|
85 |
+
description="Upload an image to classify the anime style category."
|
86 |
+
)
|
87 |
+
|
88 |
+
if __name__ == "__main__":
|
89 |
+
iface.launch()
|
90 |
+
```
|
91 |
+
|
92 |
+
---
|
93 |
+
|
94 |
+
## **Intended Use:**
|
95 |
+
|
96 |
+
The **Anime-Classification-v1.0** model is designed to classify anime-related images. Potential use cases include:
|
97 |
+
|
98 |
+
- **Content Tagging:** Automatically label anime artwork on platforms or apps.
|
99 |
+
- **Recommendation Engines:** Enhance personalized anime content suggestions.
|
100 |
+
- **Digital Art Curation:** Organize galleries by anime style for artists and fans.
|
101 |
+
- **Dataset Filtering:** Categorize and filter images during dataset creation.
|