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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- ru
|
| 5 |
+
tags:
|
| 6 |
+
- vision
|
| 7 |
+
- image-classification
|
| 8 |
+
- style-recognition
|
| 9 |
+
- anime
|
| 10 |
+
- danbooru
|
| 11 |
+
- artist-identification
|
| 12 |
+
- few-shot
|
| 13 |
+
- aniworldai
|
| 14 |
+
- onnx
|
| 15 |
+
license: apache-2.0
|
| 16 |
+
base_model: facebook/convnext-tiny-224
|
| 17 |
+
library_name: onnxruntime
|
| 18 |
+
pipeline_tag: image-classification
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# 🎨 Author_ID — Anime Artist Style Recognition
|
| 22 |
+
|
| 23 |
+
<div align="center">
|
| 24 |
+
<a href="https://aniworldai.org/">
|
| 25 |
+
<img src="https://img.shields.io/badge/AniWorldAI-Official-blue?style=for-the-badge&logo=web" alt="AniWorldAI Website">
|
| 26 |
+
</a>
|
| 27 |
+
<a href="https://t.me/aniworldai">
|
| 28 |
+
<img src="https://img.shields.io/badge/Telegram-Channel-2CA5E0?style=for-the-badge&logo=telegram" alt="Telegram Channel">
|
| 29 |
+
</a>
|
| 30 |
+
<a href="https://t.me/aniworld_bot">
|
| 31 |
+
<img src="https://img.shields.io/badge/🔥_Full_3000_Authors-Try_in_Bot-orange?style=for-the-badge&logo=telegram" alt="Try Full Version">
|
| 32 |
+
</a>
|
| 33 |
+
</div>
|
| 34 |
+
|
| 35 |
+
<br>
|
| 36 |
+
|
| 37 |
+
## 🇬🇧 English Description
|
| 38 |
+
|
| 39 |
+
**Author_ID** is an AI model that recognizes the **artistic style** of anime illustrations and identifies the most likely artist from **Danbooru** database.
|
| 40 |
+
|
| 41 |
+
Think of it as **"Shazam for anime art"** — upload any illustration and instantly discover who drew it or whose style it resembles.
|
| 42 |
+
|
| 43 |
+
### 🧠 Architecture: Face ID for Art
|
| 44 |
+
|
| 45 |
+
This model is built using the same architectural principles as **Apple Face ID**:
|
| 46 |
+
|
| 47 |
+
| Face ID | Author_ID |
|
| 48 |
+
|---------|-----------|
|
| 49 |
+
| Encodes facial features into embedding | Encodes artistic style into embedding |
|
| 50 |
+
| Compares with stored face template | Compares with artist style centroids |
|
| 51 |
+
| Works with one photo enrollment | Works with few-shot artist samples |
|
| 52 |
+
|
| 53 |
+
The model generates a **512-dimensional style embedding** and compares it against precomputed artist centroids using cosine similarity.
|
| 54 |
+
|
| 55 |
+
### ⚡ Few-Shot Learning
|
| 56 |
+
|
| 57 |
+
Unlike traditional classifiers that require thousands of samples per class, Author_ID uses a **metric learning** approach:
|
| 58 |
+
|
| 59 |
+
- **No retraining needed** to add new artists
|
| 60 |
+
- Just compute centroid from **3-5 sample images**
|
| 61 |
+
- Instantly searchable in the embedding space
|
| 62 |
+
|
| 63 |
+
### 📦 Model Versions
|
| 64 |
+
|
| 65 |
+
| Version | Authors | Availability |
|
| 66 |
+
|---------|---------|--------------|
|
| 67 |
+
| **Demo (this repo)** | 500 | Free download |
|
| 68 |
+
| **Full** | 3000+ | [Telegram Bot](https://t.me/aniworld_bot) |
|
| 69 |
+
|
| 70 |
+
### 🏷️ Output Format
|
| 71 |
+
|
| 72 |
+
Returns top-5 most similar artists with confidence scores:
|
| 73 |
+
```
|
| 74 |
+
(artist:hiten:0.87), (artist:saitom:0.72), (artist:anmi:0.68), ...
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## 🇷🇺 Описание на русском
|
| 80 |
+
|
| 81 |
+
**Author_ID** — это ИИ-модель, которая распознаёт **художественный стиль** аниме-иллюстраций и определяет наиболее вероятного автора из базы **Danbooru**.
|
| 82 |
+
|
| 83 |
+
Можно сказать, это **"Shazam для аниме-артов"** — загрузите любую картинку и мгновенно узнайте, кто её нарисовал или чей стиль она напоминает.
|
| 84 |
+
|
| 85 |
+
### 🧠 Архитектура: Face ID для арта
|
| 86 |
+
|
| 87 |
+
Модель построена по тем же принципам, что и **Apple Face ID**:
|
| 88 |
+
|
| 89 |
+
| Face ID | Author_ID |
|
| 90 |
+
|---------|-----------|
|
| 91 |
+
| Кодирует черты лица в эмбеддинг | Кодирует стиль рисунка в эмбеддинг |
|
| 92 |
+
| Сравнивает с сохранённым шаблоном | Сравнивает с центроидами авторов |
|
| 93 |
+
| Работает с одним фото при регистрации | Работает с few-shot примерами |
|
| 94 |
+
|
| 95 |
+
Модель генерирует **512-мерный вектор стиля** и сравнивает его с предрассчитанными центроидами авторов через косинусное сходство.
|
| 96 |
+
|
| 97 |
+
### ⚡ Few-Shot обучение
|
| 98 |
+
|
| 99 |
+
В отличие от классических классификаторов, Author_ID использует **metric learning**:
|
| 100 |
+
|
| 101 |
+
- **Не требует переобучения** для новых авторов
|
| 102 |
+
- Достаточно **3-5 примеров** для создания центроида
|
| 103 |
+
- Мгновенный поиск в пространстве эмбеддингов
|
| 104 |
+
|
| 105 |
+
### 📦 Версии модели
|
| 106 |
+
|
| 107 |
+
| Версия | Авторов | Доступность |
|
| 108 |
+
|--------|---------|-------------|
|
| 109 |
+
| **Demo (этот репо)** | 500 | Бесплатно |
|
| 110 |
+
| **Full** | 3000+ | [Telegram Bot](https://t.me/aniworld_bot) |
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
+
|
| 114 |
+
## 🚀 How to Use / Как использовать
|
| 115 |
+
|
| 116 |
+
### Installation / Установка
|
| 117 |
+
```bash
|
| 118 |
+
pip install onnxruntime onnx pillow numpy
|
| 119 |
+
# or for GPU / или для GPU:
|
| 120 |
+
pip install onnxruntime-gpu onnx pillow numpy
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### Inference / Инференс
|
| 124 |
+
|
| 125 |
+
```python
|
| 126 |
+
import onnxruntime as ort
|
| 127 |
+
import onnx
|
| 128 |
+
import numpy as np
|
| 129 |
+
from PIL import Image
|
| 130 |
+
import json
|
| 131 |
+
|
| 132 |
+
class AuthorID:
|
| 133 |
+
"""
|
| 134 |
+
Author_ID: Anime Artist Style Recognition
|
| 135 |
+
Single ONNX file contains: model + centroids + author names
|
| 136 |
+
"""
|
| 137 |
+
|
| 138 |
+
def __init__(self, onnx_path):
|
| 139 |
+
# Load metadata (author names embedded in ONNX)
|
| 140 |
+
model_onnx = onnx.load(onnx_path)
|
| 141 |
+
self.names = []
|
| 142 |
+
self.input_size = 384
|
| 143 |
+
|
| 144 |
+
for prop in model_onnx.metadata_props:
|
| 145 |
+
if prop.key == "author_names":
|
| 146 |
+
self.names = json.loads(prop.value)
|
| 147 |
+
elif prop.key == "input_size":
|
| 148 |
+
self.input_size = int(prop.value)
|
| 149 |
+
|
| 150 |
+
# Create inference session
|
| 151 |
+
providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
|
| 152 |
+
self.session = ort.InferenceSession(onnx_path, providers=providers)
|
| 153 |
+
|
| 154 |
+
# ImageNet normalization
|
| 155 |
+
self.mean = np.array([0.485, 0.456, 0.406], dtype=np.float32).reshape(1, 3, 1, 1)
|
| 156 |
+
self.std = np.array([0.229, 0.224, 0.225], dtype=np.float32).reshape(1, 3, 1, 1)
|
| 157 |
+
|
| 158 |
+
def preprocess(self, image_path):
|
| 159 |
+
img = Image.open(image_path)
|
| 160 |
+
|
| 161 |
+
# Handle transparency
|
| 162 |
+
if img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info):
|
| 163 |
+
bg = Image.new('RGB', img.size, (255, 255, 255))
|
| 164 |
+
img = img.convert('RGBA')
|
| 165 |
+
bg.paste(img, mask=img.split()[3])
|
| 166 |
+
img = bg
|
| 167 |
+
else:
|
| 168 |
+
img = img.convert('RGB')
|
| 169 |
+
|
| 170 |
+
img = img.resize((self.input_size, self.input_size), Image.BILINEAR)
|
| 171 |
+
|
| 172 |
+
img_np = np.array(img, dtype=np.float32) / 255.0
|
| 173 |
+
img_np = img_np.transpose(2, 0, 1)[np.newaxis, ...]
|
| 174 |
+
img_np = (img_np - self.mean) / self.std
|
| 175 |
+
|
| 176 |
+
return img_np
|
| 177 |
+
|
| 178 |
+
def predict(self, image_path, top_k=5):
|
| 179 |
+
"""Returns list of (author_name, similarity_score)"""
|
| 180 |
+
img_np = self.preprocess(image_path)
|
| 181 |
+
top_indices, top_scores = self.session.run(None, {'image': img_np})
|
| 182 |
+
|
| 183 |
+
results = []
|
| 184 |
+
for idx, score in zip(top_indices[0][:top_k], top_scores[0][:top_k]):
|
| 185 |
+
results.append((self.names[idx], float(score)))
|
| 186 |
+
|
| 187 |
+
return results
|
| 188 |
+
|
| 189 |
+
def predict_tags(self, image_path, top_k=5):
|
| 190 |
+
"""Returns formatted tags: (artist:name:score)"""
|
| 191 |
+
results = self.predict(image_path, top_k)
|
| 192 |
+
return [f"(artist:{name}:{score:.2f})" for name, score in results]
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
# === Example Usage ===
|
| 196 |
+
if __name__ == "__main__":
|
| 197 |
+
# Initialize (once)
|
| 198 |
+
model = AuthorID("author_id_500.onnx")
|
| 199 |
+
|
| 200 |
+
# Predict
|
| 201 |
+
results = model.predict("your_image.jpg", top_k=5)
|
| 202 |
+
|
| 203 |
+
print("🎨 Detected artist styles:")
|
| 204 |
+
for author, score in results:
|
| 205 |
+
print(f" {author}: {score:.1%}")
|
| 206 |
+
|
| 207 |
+
# Or get formatted tags
|
| 208 |
+
tags = model.predict_tags("your_image.jpg")
|
| 209 |
+
print("\n📝 Tags:", ", ".join(tags))
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
### Expected Output / Пример вывода
|
| 213 |
+
```
|
| 214 |
+
🎨 Detected artist styles:
|
| 215 |
+
hiten_(hitenkei): 87.3%
|
| 216 |
+
saitom: 71.8%
|
| 217 |
+
anmi: 68.2%
|
| 218 |
+
kantoku: 65.1%
|
| 219 |
+
mishima_kurone: 62.4%
|
| 220 |
+
|
| 221 |
+
📝 Tags: (artist:hiten_(hitenkei):0.87), (artist:saitom:0.72), (artist:anmi:0.68), (artist:kantoku:0.65), (artist:mishima_kurone:0.62)
|
| 222 |
+
```
|
| 223 |
+
|
| 224 |
+
---
|
| 225 |
+
|
| 226 |
+
## 📊 Technical Details / Технические детали
|
| 227 |
+
|
| 228 |
+
| Parameter | Value |
|
| 229 |
+
|-----------|-------|
|
| 230 |
+
| Backbone | ConvNeXt-Tiny |
|
| 231 |
+
| Embedding dim | 512 |
|
| 232 |
+
| Input size | 384×384 |
|
| 233 |
+
| Training data | Danbooru (filtered) |
|
| 234 |
+
| Metric | Cosine similarity |
|
| 235 |
+
| Format | ONNX (opset 17) |
|
| 236 |
+
|
| 237 |
+
---
|
| 238 |
+
|
| 239 |
+
## ⚠️ Limitations / Ограничения
|
| 240 |
+
|
| 241 |
+
- Works best on **anime/manga style** illustrations
|
| 242 |
+
- May confuse artists with very similar styles
|
| 243 |
+
- Confidence drops on **heavily cropped** or **low-quality** images
|
| 244 |
+
- Demo version limited to **500 authors**
|
| 245 |
+
|
| 246 |
+
---
|
| 247 |
+
|
| 248 |
+
<div align="center">
|
| 249 |
+
|
| 250 |
+
## 🔥 Want the full 3000+ artist version?
|
| 251 |
+
|
| 252 |
+
<a href="https://t.me/aniworld_bot">
|
| 253 |
+
<img src="https://img.shields.io/badge/Try_Full_Version-Telegram_Bot-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram Bot">
|
| 254 |
+
</a>
|
| 255 |
+
|
| 256 |
+
<br><br>
|
| 257 |
+
|
| 258 |
+
**More AI Models & News:**
|
| 259 |
+
|
| 260 |
+
<a href="https://aniworldai.org/">
|
| 261 |
+
<img src="https://img.shields.io/badge/🌐_AniWorldAI.org-Website-blue?style=flat&logo=google-chrome" alt="Website">
|
| 262 |
+
</a>
|
| 263 |
+
<a href="https://t.me/aniworldai">
|
| 264 |
+
<img src="https://img.shields.io/badge/📢_Subscribe-Telegram_Channel-2CA5E0?style=flat&logo=telegram" alt="Channel">
|
| 265 |
+
</a>
|
| 266 |
+
<a href="https://huggingface.co/AniWorldAI">
|
| 267 |
+
<img src="https://img.shields.io/badge/🤗_More_Models-HuggingFace-yellow?style=flat" alt="HuggingFace">
|
| 268 |
+
</a>
|
| 269 |
+
|
| 270 |
+
</div>
|