MobileNetV4 Emotion Recognition Model ๐ŸŽญ

FER2013 ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ ํ•™์Šต๋œ MobileNetV4 ๊ธฐ๋ฐ˜์˜ ๊ฐ์ • ์ธ์‹ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.

๋ชจ๋ธ ๊ฐœ์š”

์ด ๋ชจ๋ธ์€ MobileNetV4๋ฅผ ๋ฐฑ๋ณธ์œผ๋กœ ์‚ฌ์šฉํ•˜์—ฌ 7๊ฐ€์ง€ ๊ฐ์ •์„ ๋ถ„๋ฅ˜ํ•ฉ๋‹ˆ๋‹ค:

  • ๐Ÿ˜  Angry (ํ™”๋‚จ)
  • ๐Ÿคข Disgust (ํ˜์˜ค)
  • ๐Ÿ˜จ Fear (๋‘๋ ค์›€)
  • ๐Ÿ˜Š Happy (ํ–‰๋ณต)
  • ๐Ÿ˜ข Sad (์Šฌํ””)
  • ๐Ÿ˜ฒ Surprise (๋†€๋žŒ)
  • ๐Ÿ˜ Neutral (๋ฌดํ‘œ์ •)

๋ชจ๋ธ ์•„ํ‚คํ…์ฒ˜

  • ๋ฐฑ๋ณธ: MobileNetV4 (timm/mobilenetv4_conv_medium.e500_r224_in1k)
  • ๋ถ„๋ฅ˜๊ธฐ: 3์ธต ์™„์ „์—ฐ๊ฒฐ์ธต (512 โ†’ 128 โ†’ 7)
  • ์ •๊ทœํ™”: Batch Normalization + Dropout (0.5)
  • ์ž…๋ ฅ ํฌ๊ธฐ: 224ร—224 RGB ์ด๋ฏธ์ง€

์„ฑ๋Šฅ

  • ๊ฒ€์ฆ ์ •ํ™•๋„(test): 62.50% (FER2013 ๊ธฐ์ค€)
  • ๋ชจ๋ธ ํฌ๊ธฐ: ์•ฝ 35MB
  • ์ถ”๋ก  ์†๋„: batch=256์—์„œ 1.41it/s

์‚ฌ์šฉ ๋ฐฉ๋ฒ•

๋น ๋ฅธ ์‹œ์ž‘

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

ํ•™์Šต ์ •๋ณด

  • ๋ฐ์ดํ„ฐ์…‹: FER2013
  • ํ•™์Šต ๋ฐฉ๋ฒ•: 2๋‹จ๊ณ„ ํ•™์Šต
    1. ๋ถ„๋ฅ˜๊ธฐ๋งŒ ํ•™์Šต (10 ์—ํฌํฌ)
    2. ์ „์ฒด ๋„คํŠธ์›Œํฌ ๋ฏธ์„ธ์กฐ์ • (15 ์—ํฌํฌ)
  • ์ตœ์ ํ™”: Adam ์˜ตํ‹ฐ๋งˆ์ด์ €
  • ํ•™์Šต๋ฅ :
    • ๋ถ„๋ฅ˜๊ธฐ: 1e-3
    • ๋ฐฑ๋ณธ: 1e-5 (๋ฏธ์„ธ์กฐ์ • ์‹œ)

๋ผ๋ฒจ ๋งคํ•‘

{
  "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

Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support