Downloads · 30 days
16
35% of all-time downloads
jihedjabnoun/egcaf-meld
egcaf-meld is a machine learning model from jihedjabnoun. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This repository contains EGCAF, the multimodal fusion architecture presented in Chapter 7 of the PhD thesis A Multimodal Approach for Emotion Recognition from Multimedia Content (Jihed Jabnoun, Faculty of Sciences of…
Downloads · 30 days
16
35% of all-time downloads
All-time downloads
46
Public
Repo size
1.1 GB
Likes
2
Public
Click a slice to open those files.
.bin1.1 GB · 100%
From the Hugging Face model README
This repository contains EGCAF, the multimodal fusion architecture presented in Chapter 7 of the PhD thesis A Multimodal Approach for Emotion Recognition from Multimedia Content (Jihed Jabnoun, Faculty of Sciences of Monastir, 2026) and in the accompanying ACIIDS 2026 paper. EGCAF recognises seven emotions (Anger, Disgust, Fear, Happiness, Neutral, Sadness, Surprise) from text, audio, and facial video in conversational utterances.
EGCAF keeps three pretrained emotion experts frozen and trains only a small fusion module on top of them: 8.07M trainable parameters out of 270.6M (97.0% frozen). The frozen experts cannot drift toward the rebalanced training distribution, which is what allows minority-class oversampling without the accuracy penalty observed in jointly trained early fusion.
The implementation class is named
HybridLateFusionToEarlyFusioninmodeling_hybrid.py, a working name from development. It is the EGCAF model described in the thesis.

Test set, 2,610 utterances. All figures come from a single run with a fixed seed (42).
| Approach | Acc | Macro-F1 | Weighted-F1 | Disgust F1 | Fear F1 |
|---|---|---|---|---|---|
| Text expert only | 58.3 | 48.2 | 59.4 | – | – |
| Audio expert only | 17.7 | 13.4 | 13.1 | – | – |
| Vision expert only | 13.2 | 10.7 | 16.4 | – | – |
| Late fusion, equal averaging (MELD-fine-tuned experts) | 61.1 | 35.1 | 56.0 | 0.078 | 0.068 |
| Early fusion, concatenation | 63.9 | 38.1 | 61.2 | 0.000 | 0.000 |
| Early fusion, cross-attention | 65.1 | 40.0 | 62.9 | 0.000 | 0.000 |
| Early fusion, concatenation + augmentation | 58.5 | 42.3 | 59.2 | 0.241 | 0.122 |
| Early fusion, emotion-specific projections + focal loss | 63.5 | 41.9 | 61.9 | 0.222 | 0.000 |
| EGCAF | 66.7 | 51.1 | 66.2 | 0.292 | 0.272 |
| Emotion | Precision | Recall | F1 | Support | Prior weights (T/A/V) | Learned weights (T/A/V) |
|---|---|---|---|---|---|---|
| Anger | 0.51 | 0.60 | 0.552 | 345 | 0.72 / 0.18 / 0.10 | 0.56 / 0.21 / 0.23 |
| Disgust | 0.50 | 0.21 | 0.292 | 68 | 0.84 / 0.09 / 0.07 | 0.16 / 0.00 / 0.84 |
| Fear | 0.35 | 0.22 | 0.272 | 50 | 0.90 / 0.06 / 0.04 | 0.07 / 0.03 / 0.91 |
| Happiness | 0.61 | 0.58 | 0.595 | 402 | 0.20 / 0.07 / 0.73 | 0.99 / 0.01 / 0.00 |
| Neutral | 0.79 | 0.79 | 0.793 | 1256 | 0.65 / 0.25 / 0.10 | 0.88 / 0.06 / 0.06 |
| Sadness | 0.59 | 0.39 | 0.470 | 208 | 0.23 / 0.73 / 0.04 | 0.68 / 0.23 / 0.09 |
| Surprise | 0.53 | 0.70 | 0.606 | 281 | 0.47 / 0.12 / 0.41 | 0.29 / 0.06 / 0.64 |
Learned weights are the final fusion weights averaged over MELD test samples of each emotion. They scale the attended representations, which already mix information across modalities, and the expert logits of all three modalities reach every classifier head unweighted. A high "vision" weight therefore means the vision-anchored representation is scaled up, not that the decision is made from facial evidence alone.

The main error patterns are:
Weighted-F1 is used here because every system reports it. Published figures are as compiled by Fu et al. (BeMERC, 2025).
| System | Weighted-F1 |
|---|---|
| BeMERC (LLM-based, ~7B parameters) | 69.78 |
| SpeechCueLLM | 67.60 |
| DGODE | 67.20 |
| M3Net | 67.05 |
| MultiEMO | 66.74 |
| EGCAF (271M total, 8.07M trainable) | 66.2 |
| UniMSE | 65.51 |
EGCAF is not state of the art: it is 3.6 weighted-F1 points below BeMERC. It is competitive with the strongest graph- and attention-based systems while training only 8M parameters. Its Disgust and Fear F1 are comparable to, not above, the strongest published systems.
These results use the MELD-trained model with no retraining on the new data.
| Dataset | Text expert only (Acc / M-F1) | EGCAF (Acc / M-F1) |
|---|---|---|
| MELD (in-domain) | 58.3 / 48.2 | 66.7 / 51.1 |
| IEMOCAP Session 5 (vision replaced by a blank frame) | 39.2 / 31.0 | 47.3 / 38.5 |
| EmoVid (film and TV clips) | 50.4 / 45.4 | 39.1 / 35.5 |
| Available modalities | Accuracy | Macro-F1 |
|---|---|---|
| Text + Audio + Vision | 66.7 | 51.1 |
| Text + Audio | 65.2 | 48.3 |
| Text + Vision | 64.8 | 47.9 |
| Text only | 60.1 | 45.2 |
| Audio + Vision | 38.2 | 28.1 |
An absent modality is replaced by a blank input of the expected shape (for example, a zero-valued frame); the model has no explicit availability mask. Degradation is small while text is available and severe without it.
pip install torch transformers librosa pillow numpy huggingface_hub
import torch
from huggingface_hub import hf_hub_download
REPO_ID = "jihedjabnoun/egcaf-meld"
model_def_path = hf_hub_download(repo_id=REPO_ID, filename="modeling_hybrid.py")
model_path = hf_hub_download(repo_id=REPO_ID, filename="pytorch_model.bin")
# Defines HybridLateFusionToEarlyFusion (EGCAF), EMOTION_LABELS and ID_TO_LABEL
exec(open(model_def_path).read())
model = HybridLateFusionToEarlyFusion(
num_labels=7,
hidden_size=512,
num_heads=8,
freeze_experts=True,
)
model.load_state_dict(torch.load(model_path, map_location="cpu"))
model.eval()
from transformers import AutoTokenizer, Wav2Vec2FeatureExtractor, ViTImageProcessor
text_tokenizer = AutoTokenizer.from_pretrained("jihedjabnoun/text-emotion-distilroberta")
audio_extractor = Wav2Vec2FeatureExtractor.from_pretrained("jihedjabnoun/hubert-emotion-recognition-v2")
vision_processor = ViTImageProcessor.from_pretrained("jihedjabnoun/vit-face-emotion-recognition")
import librosa
import numpy as np
from PIL import Image
def predict_emotion(text, audio_path, face_images):
# Text
text_inputs = text_tokenizer(text, padding="max_length", truncation=True,
max_length=128, return_tensors="pt")
# Audio: 3 seconds at 16 kHz
audio, _ = librosa.load(audio_path, sr=16000)
target_length = 3 * 16000
audio = audio[:target_length] if len(audio) > target_length else \
np.pad(audio, (0, target_length - len(audio)), mode="constant")
audio_inputs = audio_extractor(audio, sampling_rate=16000,
return_tensors="pt", padding=True)
# Vision: up to 5 face frames, averaged pixel-wise into one image (as in training)
faces = [f.resize((224, 224), Image.Resampling.LANCZOS) for f in face_images[:5]]
vision_inputs = vision_processor(images=faces, return_tensors="pt")
pixel_values = vision_inputs["pixel_values"].mean(dim=0, keepdim=True)
with torch.no_grad():
outputs = model(
input_ids=text_inputs["input_ids"],
attention_mask=text_inputs["attention_mask"],
audio_values=audio_inputs["input_values"],
audio_attention_mask=torch.ones_like(audio_inputs["input_values"]),
pixel_values=pixel_values,
)
logits = outputs["logits"]
probs = torch.softmax(logits, dim=-1)
predicted_id = torch.argmax(logits, dim=-1).item()
result = {
"predicted_emotion": ID_TO_LABEL[predicted_id],
"confidence": probs[0][predicted_id].item(),
"all_probabilities": {ID_TO_LABEL[i]: probs[0][i].item() for i in range(7)},
}
if hasattr(model, "last_expert_logits"):
result["expert_predictions"] = {
m: ID_TO_LABEL[torch.argmax(model.last_expert_logits[m]).item()]
for m in ["text", "audio", "vision"]
}
if hasattr(model, "last_gate_values"):
# Gate scores for the predicted emotion, before the confidence adjustment and priors
gates = model.last_gate_values[predicted_id, 0, :].numpy()
result["gate_values"] = {"text": float(gates[0]), "audio": float(gates[1]),
"vision": float(gates[2])}
return result
EGCAF is a research model. It is not suitable for clinical diagnosis, hiring decisions, surveillance, or any high-stakes decision without human review.
pytorch_model.bin: model weightsconfig.json: model configurationmodeling_hybrid.py: model implementation (class HybridLateFusionToEarlyFusion)detailed_results.json: evaluation metricstest_predictions_detailed.csv: all MELD test predictionsegcaf_arch.png: architecture diagramconfusion_matrix.png: MELD test confusion matrixaugmentation_log.json: data augmentation details@phdthesis{jabnoun2026multimodal,
title = {A Multimodal Approach for Emotion Recognition from Multimedia Content},
author = {Jabnoun, Jihed},
school = {Faculty of Sciences of Monastir, University of Monastir},
year = {2026}
}
@inproceedings{jabnoun2026adaptive,
title = {Adaptive Multimodal Fusion for Interpretable and Efficient Conversational Emotion Recognition},
author = {Jabnoun, Jihed and Maraoui, Mohsen and Zrigui, Mounir},
booktitle = {18th Asian Conference on Intelligent Information and Database Systems (ACIIDS)},
year = {2026},
note = {Accepted}
}