Downloads · 30 days
7
1% of all-time downloads
lrzjason/anime_portrait_vit
anime_portrait_vit is a image classification model from lrzjason. Use it when you need a label for an image. It is set up for transformers. The card lists the license as apache-2.0.
Trained a vit model to do classification on anime dataset.
Downloads · 30 days
7
1% of all-time downloads
All-time downloads
637
Public
Parameters
85.8M
347 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors343 MB · 99%
From the Hugging Face model README
Trained a vit model to do classification on anime dataset.
Divided into four categories: head_only, upperbody, knee_level, fullbody




from datasets import load_dataset
from PIL import Image
from transformers import ViTImageProcessor, ViTForImageClassification, TrainingArguments, Trainer
import torch
import numpy as np
from datasets import load_metric
import os
import shutil
model_name_or_path = 'lrzjason/anime_portrait_vit'
image_processor = ViTImageProcessor.from_pretrained(model_name_or_path)
model = ViTForImageClassification.from_pretrained(model_name_or_path)
input_dir = '/path/to/dir'
file = 'example.jpg'
image = Image.open(os.path.join(input_dir, file))
inputs = image_processor(image, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
# model predicts one of the 1000 ImageNet classes
predicted_label = logits.argmax(-1).item()
print(f'predicted_label: {model.config.id2label[predicted_label]}')
Using this dataset: https://huggingface.co/datasets/animelover/genshin-impact-images