从wider_attribute数据集中提取性别

本文提供了一个从wider_attribute数据集中提取性别属性的方法;并提供了数据集的下载链接。

目录

1、数据集说明 

2、方法

3、附

4. Citation


1、数据集说明 

WIDER Attribute是一个大规模的人类属性数据集。它包含属于 30 个场景类别的 13789 个图像,以及 57524 个人体边界框,每个边界框都用 14 个二进制属性进行注释。

        数据集一览:

 

 

        可见,该数据集也是从大图里面标注了人体的边框,并提供了每个人的属性集的。

        此外,该数据集相比之前的其他数据集也有一定优势:

        数据标注格式为:

{
	"images"		: [image],			# A list of "image" (see below)
	"attribute_id_map"	: {str : str},			# A dict, mapping attribute_id to attribute_name
	"scene_id_map"		: {str : str}			# A dict, mapping scene_id to scene_name
}

image {
	"targets"		: [target],			# A list of "target" (see below)
	"file_name"		: str,				# Image file name
	"scene_id"		: int				# Scene id
}

target {
	"attribute"		: [int]				# A list of int, the i-th element corresponds to the i-th attribute, and the value could be 1(possitive), -1(negative) or 0 (unspecified)
	"bbox"			: [x, y, width, height] 	# Human bounding box
}

2、方法

通过以下代码,可以从数据集中解析出每个图片的属性,并根据性别存放到不同文件夹:

"""
parse person's gender from wider_attribute
"""
import os
import cv2
import glob
import json
import numpy as np


def xywh2xyxy(xywh):
    x1, y1, w, h = xywh
    x2 = x1 + w
    y2 = y1 + h
    return [int(x1), int(y1), int(x2), int(y2)]


def main(raw_path, new_dataset_path):
    classes = ['0_Female', '1_Male']
    os.makedirs(new_dataset_path, exist_ok=True)
    Male_path = os.path.join(new_dataset_path, '1_Male')
    Female_path = os.path.join(new_dataset_path, '0_Female')
    os.makedirs(Male_path, exist_ok=True)
    os.makedirs(Female_path, exist_ok=True)

    anno_files = glob.glob(raw_path + '/annotation/*.json')
    for anno_file in anno_files:
        print("\n\nProcessing: {}".format(anno_file))
        anno = json.load(open(anno_file, 'r'))
        images = anno['images']
        attribute_id_map = anno['attribute_id_map']

        imgs_num = len(images)
        for idx, image in enumerate(images):
            print("\rdeal: [{}/{}]".format(idx + 1, imgs_num), end='')
            file_name = image['file_name']
            img_cv = cv2.imread(os.path.join(raw_path, 'Image', file_name))
            H, W, _ = img_cv.shape
            targets = image['targets']

            for t_i, target in enumerate(targets):
                attribute = target['attribute']
                if attribute[0] == 0:
                    continue
                cls_id = 1 if attribute[0] == 1 else 0
                class_name = classes[cls_id]
                bbox = target['bbox']
                x1, y1, x2, y2 = xywh2xyxy(bbox)
                x1, x2 = np.clip([x1, x2], 0, W)
                y1, y2 = np.clip([y1, y2], 0, H)
                if y2-y1 <= 0 or x2-x1 <= 0:
                    continue
                target_cv = img_cv[y1:y2, x1:x2, :]
                # print(target_cv.shape, [x1, y1, x2, y2])

                name = os.path.splitext(file_name.split('/')[-1])[0] + '_{}.jpg'.format(t_i)
                img_save_to = os.path.join(new_dataset_path, class_name, 'wider_' + name)
                write_status = cv2.imwrite(img_save_to, target_cv)
                assert write_status, "target image [{}] write error!".format(img_save_to)


if __name__ == '__main__':
    raw_path = '../wider_attribute'
    new_path = '../datasets/gender_dataset_parse/from_wider'
    main(raw_path, new_path)

3、附

下载链接: https://pan.baidu.com/s/1mbxI6npcxsx0FHQh2DV_OQ?pwd=b1xw 提取码: b1xw 

4. Citation

@inproceedings{li2016human,
  author = {Li, Yining and Huang, Chen and Loy, Chen Change and Tang, Xiaoou},
  title = {Human Attribute Recognition by Deep Hierarchical Contexts},
  booktitle = {European Conference on Computer Vision},
  year = {2016}
}

论文:http://personal.ie.cuhk.edu.hk/~ccloy/files/eccv_2016_human.pdf 

### OpenCV相关的计算机视觉任务数据集 对于计算机视觉任务而言,数据集的选择至关重要。OpenCV作为一个广泛使用的开源计算机视觉库,在处理图像和视频方面提供了强大的功能和支持[^2]。 #### 常见的数据集分类及其用途 1. **基础图像操作** 对于学习基本的图像变换、滤波等操作,可以使用简单的合成图片或者官方文档中的测试图片集合。这类资源通常随OpenCV安装包一起提供,方便初学者快速上手[^3]。 2. **物体检测与识别** - COCO (Common Objects in Context): 包含超过30万张高质量标注图象,覆盖80种不同类别对象实例分割、关键点检测等多种任务。 - PASCAL VOC: 提供了多种挑战赛的任务设置,如目标定位、分类等,适用于评估算法性能。 3. **面部特征分析** - CelebA Dataset: 收录了大量名人面孔照片,并带有属性标签(性别、年龄等),非常适合用于人脸检测、表情识别等领域研究。 - WIDER FACE: 是一个人脸检测专用的大规模数据库,具有丰富的尺度变化样本分布特性。 4. **人体姿态估计** Human Pose Estimation作为计算机视觉的重要组成部分之一,其常用到的数据集包括MPII Human Pose 和COCO keypoints challenge,这些都涉及到对人体各个部位的关键点位置进行精确标记[^4]。 5. **立体视觉与深度感知** KITTI Vision Benchmark Suite不仅限于自动驾驶领域内的应用开发,还特别适合用来练习双目视差计算、光流场估算等相关技能。 为了更好地利用上述提到的各种公开可用的数据源开展基于OpenCV框架下的项目实践工作,建议访问官方网站获取最新版本的支持说明文件以及社区贡献者分享的经验教程链接[^1]。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AICVHub

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值