Downloads · 30 days
12
9% of all-time downloads
pollux435/mobilenet-v4-emotion
mobilenet-v4-emotion is a image classification model from pollux435. Use it when you need a label for an image. The card lists the license as mit.
FER2013 데이터셋으로 학습된 MobileNetV4 기반의 감정 인식 모델입니다.
Downloads · 30 days
12
9% of all-time downloads
All-time downloads
127
Public
Repo size
74 MB
Likes
0
Public
Click a slice to open those files.
.bin37.1 MB · 100%
From the Hugging Face model README
FER2013 데이터셋으로 학습된 MobileNetV4 기반의 감정 인식 모델입니다.
이 모델은 MobileNetV4를 백본으로 사용하여 7가지 감정을 분류합니다:
from transformers import AutoConfig
from modeling_mobilenet_v4_emotion import MobileNetV4EmotionClassifier
from preprocessing import preprocess_image
import torch
# 모델 로드
config = AutoConfig.from_pretrained("pollux435/mobilenet-v4-emotion", trust_remote_code=True)
model = MobileNetV4EmotionClassifier.from_pretrained("pollux435/mobilenet-v4-emotion", trust_remote_code=True)
model.eval()
# 이미지 예측
image_path = "your_image.jpg"
pixel_values = preprocess_image(image_path)
with torch.no_grad():
outputs = model(pixel_values)
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class_id = outputs.logits.argmax().item()
predicted_emotion = config.id2label[str(predicted_class_id)]
confidence = probabilities[0][predicted_class_id].item()
print(f"예측된 감정: {predicted_emotion}")
print(f"신뢰도: {confidence:.4f}")
이 모델을 사용해서 쉽게 전이학습을 할 수 있습니다:
from transformers import AutoConfig
from modeling_mobilenet_v4_emotion import MobileNetV4EmotionClassifier
# 기존 모델 로드
model = MobileNetV4EmotionClassifier.from_pretrained("pollux435/mobilenet-v4-emotion", trust_remote_code=True)
# 새로운 클래스 수로 분류기 교체 (예: 3개 클래스)
import torch.nn as nn
in_features = model.classifier[-1].in_features
model.classifier[-1] = nn.Linear(in_features, 3)
# 이제 여러분의 데이터로 학습하세요!
pip install torch torchvision transformers timm pillow numpy
{
"0": "angry",
"1": "disgust",
"2": "fear",
"3": "happy",
"4": "sad",
"5": "surprise",
"6": "neutral"
}
| 입력 이미지 | 예측 감정 | 신뢰도 |
|---|---|---|
| 😊 | Happy | 0.89 |
| 😢 | Sad | 0.76 |
| 😠 | Angry | 0.82 |
이 모델을 사용하실 경우 다음과 같이 인용해 주세요:
@misc{mobilenetv4-emotion-2024,
title={MobileNetV4 Based Emotion Recognition Model},
author={pollux435},
year={2024},
publisher={Hugging Face},
note={Trained on FER2013 dataset}
}
MIT License