Downloads · 30 days
0
Moxieeixom/subtlety-detector-backend
subtlety-detector-backend is a machine learning model from Moxieeixom. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
FastAPI service that classifies facial emotions from a cropped face image.
Downloads · 30 days
0
Access
Public
Updated Jul 23, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py11.6 KB · 71%
From the Hugging Face model README
FastAPI service that classifies facial emotions from a cropped face image.
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python app.py
# → http://localhost:7860
| Method | Path | Body | Returns |
|---|---|---|---|
| GET | /health | — | Service & model status |
| GET | /emotions | — | Canonical 8-emotion list |
| POST | /predict | multipart/form-data field [email protected] | 8 emotion probabilities |
| POST | /predict_json | {"image": "data:image/jpeg;base64,..."} | 8 emotion probabilities |
{
"emotions": [
{"key": "neutral", "label_en": "neutral", "label_zh": "平静", "emoji_mild": "😐", "emoji_strong": "😐", "probability": 0.12},
...
{"key": "happy", ...}
],
"top_emotion": "happy",
"top_probability": 0.78,
"inference_ms": 142.5
}
The default is trpakov/vit-face-expression (7-class). To use a 8-class
AffectNet model:
SUBTLETY_MODEL_ID=your-org/your-model as an env var, orinference.py → DEFAULT_MODEL_IDemotions.py → TRPAKOV_IDX_TO_EMOTION to match the new model's
output order (or replace _remap_to_8() to copy directly)backend/ folder to the Space's repoFree CPU tier gives 2 vCPU / 16 GB RAM — enough for ~150ms inference per request on a 224×224 face crop.