共计 2012 个字符,预计需要花费 6 分钟才能阅读完成。
背景介绍
CK+(Extended Cohn-Kanade)数据集是面部表情识别领域最具影响力的基准数据集之一,由卡内基梅隆大学于 2010 年发布。该数据集在原始 Cohn-Kanade 数据集基础上扩展,包含 123 名受试者的 593 个视频序列,涵盖 7 种基本表情(愤怒、厌恶、恐惧、快乐、悲伤、惊讶和中性)。其学术价值体现在三个方面:

- 高精度标注:每帧图像包含 68 个面部关键点坐标和 Action Units 强度值
- 标准化采集环境:在受控光照条件下使用固定摄像机采集
- 广泛验证:被 ECCV、CVPR 等顶会论文引用超过 2000 次
技术解析
数据结构
数据集目录采用层次化组织:
CK+
├── Emotions
│ ├── S005_001_00000011_emotion.txt
│ └── ...
├── FACS
│ ├── S005_001_00000011_facs.txt
│ └── ...
└── cohn-kanade-images
├── S005
│ ├── 001
│ │ ├── S005_001_00000001.png
│ │ └── ...
│ └── ...
└── ...
关键特征
- 时空连续性:每个表情序列从中性表情开始到峰值表情结束
- 多模态标注:同时提供 FACS 编码和离散表情标签
- 高分辨率:图像尺寸为 640×490 或 640×480 像素
实战指南
数据加载示例
import os
import cv2
import numpy as np
class CKPlusLoader:
def __init__(self, root_path):
self.root = root_path
self._build_index()
def _build_index(self):
self.samples = []
for subject in os.listdir(os.path.join(self.root, 'cohn-kanade-images')):
for sequence in os.listdir(os.path.join(self.root, 'cohn-kanade-images', subject)):
img_dir = os.path.join(self.root, 'cohn-kanade-images', subject, sequence)
emotion_file = os.path.join(self.root, 'Emotions', subject, sequence + '_emotion.txt')
if os.path.exists(emotion_file):
with open(emotion_file) as f:
emotion = int(float(f.readline().strip()))
self.samples.append((img_dir, emotion))
def __getitem__(self, idx):
img_dir, emotion = self.samples[idx]
images = []
for img_name in sorted(os.listdir(img_dir)):
img_path = os.path.join(img_dir, img_name)
img = cv2.imread(img_path, cv2.IMREAD_GRAYSCALE)
images.append(img)
return np.stack(images), emotion
性能优化
内存映射技术
对于大型实验,建议使用 HDF5 格式存储预处理后的数据:
import h5py
# 创建 HDF5 文件
with h5py.File('ck_preprocessed.h5', 'w') as hf:
for i, (images, label) in enumerate(loader):
hf.create_dataset(f'sample_{i}/images', data=images, compression='gzip')
hf.create_dataset(f'sample_{i}/label', data=label)
避坑指南
数据不均衡解决方案
CK+ 中各类表情样本数量差异明显(快乐占比约 40%),推荐采用:
- 分层抽样:确保每 batch 包含所有类别
- 样本加权:在损失函数中设置类别权重
class_counts = np.bincount(labels) class_weights = 1. / class_counts sample_weights = class_weights[labels]
扩展应用
跨数据集融合
CK+ 常与以下数据集联合使用:
- FER2013:补充自然场景样本
- AffectNet:增加文化多样性
- RAF-DB:丰富遮挡场景
融合时应统一:
– 图像尺寸(建议 48×48)
– 标签体系(采用 7 类基本表情)
– 数据增强策略(相同的随机裁剪 / 翻转参数)
思考题
- 如何利用 CK+ 的时序信息改进静态图像分类模型?
- 当需要识别复合表情时,FACS 标注相比离散标签有哪些优势?
- 在数据量有限的情况下,哪些迁移学习策略对 CK+ 最有效?
正文完
发表至: 未分类
近两天内
