Downloads · 30 days
474
65% of all-time downloads
Mitchins/image-medium-classifier-efficientnet-b0-v1
image-medium-classifier-efficientnet-b0-v1 is a image classification model from Mitchins. Use it when you need a label for an image. It is set up for timm. The card lists the license as openrail.
Fast, lightweight classifier for distinguishing photographs from anime and 3D rendered images.
Downloads · 30 days
474
65% of all-time downloads
All-time downloads
725
Public
Parameters
4.1M
16.2 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors16.2 MB · 100%
From the Hugging Face model README
Fast, lightweight classifier for distinguishing photographs from anime and 3D rendered images.
| Class | Precision | Recall | F1-Score |
|---|---|---|---|
| anime | 0.98 | 0.99 | 0.99 |
| real | 0.98 | 0.98 | 0.98 |
| rendered | 0.96 | 0.93 | 0.94 |
| macro avg | 0.97 | 0.97 | 0.97 |
from PIL import Image
import torch
from torchvision import transforms
import timm
from safetensors.torch import load_file
# Load model
model = timm.create_model('efficientnet_b0', num_classes=3, pretrained=False)
state_dict = load_file('model.safetensors')
model.load_state_dict(state_dict)
model.eval()
# Prepare image
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
image = Image.open('image.jpg').convert('RGB')
x = transform(image).unsqueeze(0)
# Predict
with torch.no_grad():
logits = model(x)
probs = torch.softmax(logits, dim=1)
pred_class = probs.argmax(dim=1).item()
labels = ['anime', 'real', 'rendered']
print(f"{labels[pred_class]}: {probs[0, pred_class]:.2%}")
OpenRAIL - Free for research and commercial use with proper attribution