(万字长文)MER-Factory:自动化构建多模态情感识别与推理数据集
MER-Factory:自动化构建多模态情感识别数据集的开源工具 MER-Factory是一个开源项目,旨在自动化构建多模态情感识别与推理(MER)数据集。该项目提供完整的数据处理流水线,支持视频、音频和图像三类输入数据,包含面部动作单元提取、音频分析、视频内容描述等核心功能。系统能够识别情感高峰时刻,综合分析视觉、音频和面部等多模态信息,最终生成包含情感识别和推理的综合性数据集。该工具支持多种A

如果这个项目对你有帮助,欢迎给 https://github.com/Lum1104/MER-Factory/ 仓库点一个 Star 🌟 ,这对我们帮助很大
在多模态情感识别(Multimodal Emotion Recognition, MER)领域,构建高质量的数据集一直是推动研究和应用的关键。MER-Factory 是一个开源工具,旨在自动化构建 MERR 数据集,支持视频、音频、图像三类数据集的输入,提供全面的数据处理能力。
项目概述
MER-Factory 提供了一整套数据处理流水线,包括面部动作单元(AU)提取、音频分析、视频分析、图像分析等模块,最终生成包含情感识别和推理的综合性数据集。

核心功能
- 面部 AU 提取:从视频中提取面部动作单元,并生成自然语言描述。
- 音频分析:提取音频、转录语音并进行语调分析。
- 视频分析:生成视频内容和上下文的综合描述。
- 图像分析:对静态图像进行情感识别,提供视觉描述和情感合成。
- 完整 MER 流水线:识别情感高峰时刻,分析所有模态(视觉、音频、面部),并综合生成情感推理摘要。
数据集支持
MER-Factory 支持视频、音频和图像三类数据集的输入,并能根据不同的需求进行处理和分析。
安装与使用
安装
请参考 MER-Factory 自动化构建多模态情感识别与推理数据集入门指南 https://blog.csdn.net/m0_57273156/article/details/149331764 进行详细的安装指导。
使用示例
# 显示所有支持的参数
python main.py --help
# 使用 Gemini 模型进行完整 MER 流水线处理
python main.py path_to_video/ output/ --type MER --silent --threshold 0.8
# 使用情感分析任务
python main.py path_to_video/ output/ --type MER --task "Sentiment Analysis" --silent
# 使用 ChatGPT 模型
python main.py path_to_video/ output/ --type MER --chatgpt-model gpt-4o --silent
# 使用本地 Ollama 模型
python main.py path_to_video/ output/ --type MER --ollama-vision-model llava-llama3:latest --ollama-text-model llama3.2 --silent
# 使用 Hugging Face 模型
python main.py path_to_video/ output/ --type MER --huggingface-model google/gemma-3n-E4B-it --silent
# 处理图像而非视频
python main.py ./images ./output --type MER
{
"video_id": "xxx",
"source_video": "video/xxx.mp4",
"chronological_emotion_peaks": [
"Peak at 4.44s: contempt (slight)",
"Peak at 5.40s: sad (slight), contempt (slight), angry (slight)",
"Peak at 6.36s: surprise (slight)",
"Peak at 7.04s: contempt (slight), sad (slight)"
],
"overall_peak_frame_info": {
"frame_number": 136,
"timestamp": 5.4,
"top_aus_intensities": {
"AU02_r": 0.91,
"AU04_r": 2.82,
"AU05_r": 0.97,
"AU09_r": 0.93,
"AU10_r": 1.14,
"AU14_r": 2.33,
"AU23_r": 0.84
}
},
"coarse_descriptions_at_peak": {
"visual_expression": "Outer brow raiser (intensity: 0.91), Brow lowerer (intensity: 2.82), Upper lid raiser (intensity: 0.97), Nose wrinkler (intensity: 0.93), Upper lip raiser (intensity: 1.14), Dimpler (intensity: 2.33), Lip tightener (intensity: 0.84)",
"visual_objective": "Two people are in the image. The person on the left appears to be a middle-aged male with a shaved head. He is wearing a dark shirt and a plaid jacket. The person on the right appears to be a female with long dark hair pulled back in a ponytail. She is wearing a light blue sweater. The background includes a window and a wall with a framed picture. Text is present at the bottom of the image.",
"audio_tone": "The speaker's tone is apologetic and slightly pleading. The pitch is moderate. The speed of speech is relatively slow. There are no significant background noises.",
"subtitles": "你在哪儿我还不知道? 我是来向你道歉的,昨天晚上真的是太了。 对不起,好吗?",
"video_content": "A man and a woman are standing in front of a window. The man is bald and wearing a black shirt with a plaid shirt over it. The woman has her back to the camera and is wearing a light blue sweater. The man is speaking and appears to be apologizing. The woman is looking down. There is a picture on the wall."
},
"final_summary": "**Part 1: Emotional Narrative**\n\nThe subject's emotional journey begins with a slight expression of contempt at 4.44s. This initial display of contempt, without further context, is difficult to interpret. At 5.40s, the emotional landscape becomes more complex. The subject experiences a peak of sadness, contempt, and anger, all at a slight intensity. This is the overall peak of emotional intensity. The facial expression at this moment is particularly revealing. The outer brow raiser, brow lowerer, upper lid raiser, nose wrinkler, upper lip raiser, dimpler, and lip tightener all contribute to a complex expression. The brow lowerer and nose wrinkler suggest anger or frustration, while the upper lip raiser and dimpler could indicate contempt or even a suppressed smile. The combination of these facial features, coupled with the sadness, suggests a state of internal conflict, possibly stemming from a situation that evokes multiple negative emotions. At 6.36s, a slight surprise is registered. This could be a reaction to something said or done by the other person in the scene. Finally, at 7.04s, the subject again displays slight contempt and sadness. This suggests a continuation of the negative emotional state, possibly a lingering resentment or disappointment. The audio tone, which is apologetic and pleading, and the subtitles, which include an apology, suggest that the man is the speaker and is trying to make amends. The woman's posture, with her back to the camera and looking down, suggests she is either listening to the apology or is feeling shame or sadness.\n\n**Part 2: Overall Assessment**\n\nThe subject's most likely overall emotional state is a combination of sadness, anger, and contempt, possibly tinged with a degree of surprise. The likely cause for this emotional state is a conflict or disagreement, as suggested by the man's apology in the subtitles (\"我是来向你道歉的,昨天晚上真的是太了。 对不起,好吗?\"). The man's apology, coupled with the woman's posture and the negative emotions displayed, suggests that the woman is the recipient of the apology and is experiencing a range of negative emotions related to the event being apologized for. The presence of contempt suggests a lingering resentment or a feeling of being wronged."
}
仪表板(Dashboard)
提供一个交互式仪表板,方便数据策展和超参数调优。用户可以测试不同的提示词,保存和运行配置,并对生成的数据进行评分。
python dashboard.py
这里支持直接对数据标注打分,预览数据,同时也支持直接修改标注内容:
在这个页面,可以可视化的编辑各个prompt,配置运行参数并直接一键运行标注
模型支持
MER-Factory 支持四种类型的模型:
- Google Gemini:需要在
.env文件中配置GOOGLE_API_KEY。 - OpenAI ChatGPT:需要在
.env文件中配置OPENAI_API_KEY,并通过--chatgpt-model指定模型。 - Ollama:本地模型,使用
--ollama-vision-model和--ollama-text-model指定模型。 - Hugging Face:支持多模态模型,如
google/gemma-3n-E4B-it等。
适用场景
MER-Factory 适用于以下场景:
- 研究人员:构建多模态情感数据集,进行模型训练和评估。
- 开发者:集成情感分析功能到应用中。
- 教育工作者:用于教学和实验,探索多模态情感识别的应用。
模型推荐
何时使用 Ollama
推荐用途:图像分析、动作单元分析、文本处理以及简单的音频转录任务。
优势:
- ✅ 支持异步调用:Ollama 支持异步调用,非常适合高效处理大型数据集
- ✅ 本地处理:无需 API 成本或速率限制
- ✅ 丰富的模型选择:访问 ollama.com 了解可用模型
- ✅ 隐私保护:所有处理都在本地完成
示例用法:
# 使用 Ollama 处理图像
python main.py ./images ./output --type image --ollama-vision-model llava-llama3:latest --ollama-text-model llama3.2 --silent
# 使用 Ollama 进行 AU 提取
python main.py video.mp4 output/ --type AU --ollama-text-model llama3.2 --silent
何时使用 ChatGPT/Gemini
推荐用途:高级视频分析、复杂的多模态推理以及高质量内容生成。
优势:
- ✅ 最先进的性能:最新的 GPT-4o 和 Gemini 模型提供卓越的推理能力
- ✅ 高级视频理解:对复杂视频分析和时间推理支持更好
- ✅ 高质量输出:更细致、更详细的情感识别和推理
- ✅ 强大的多模态集成:在文本、图像和视频模态上表现优异
示例用法:
python main.py video.mp4 output/ --type MER --chatgpt-model gpt-4o --silent
python main.py video.mp4 output/ --type MER --silent
权衡:存在 API 成本和速率限制,但通常为复杂的情感推理任务提供最高质量的结果。
何时使用 Hugging Face 模型
推荐用途:当您需要最新的最先进的模型或 Ollama 不支持的特定功能时。
自定义模型集成:
如果您想使用最新的 Hugging Face 模型或 Ollama 不支持的功能:
-
选项 1 - 自行实现:导航至
agents/models/hf_models/__init__.py,按照现有模式注册您的模型并实现所需功能。 -
选项 2 - 请求支持:在我们的仓库 / 或此 CSDN 中提交问题,告诉我们您希望我们支持的模型,我们会考虑添加。
当前支持的模型:google/gemma-3n-E4B-it 以及其他在 HF 模型目录中列出的模型。
结语
MER-Factory 是一个功能强大的工具,旨在简化多模态情感识别数据集的构建过程。通过自动化的数据处理流水线和对多种模型的支持,用户可以高效地生成高质量的情感数据集,推动相关领域的研究和应用发展。
如需了解更多信息,请访问 MER-Factory 官方文档。
火山引擎开发者社区是火山引擎打造的AI技术生态平台,聚焦Agent与大模型开发,提供豆包系列模型(图像/视频/视觉)、智能分析与会话工具,并配套评测集、动手实验室及行业案例库。社区通过技术沙龙、挑战赛等活动促进开发者成长,新用户可领50万Tokens权益,助力构建智能应用。
更多推荐
所有评论(0)