🚀 MiVOLO V2模型介绍
MiVOLO V2是一款用于年龄和性别估计的先进多输入Transformer模型,它在专有和开源数据集上进行训练,为年龄和性别估计任务带来了卓越的性能。
🤗 演示空间 |
🌐 Github仓库 |
📜 MiVOLO论文 (2023)
📜 MiVOLO论文 (2024)
🚀 快速开始
推理要求与模型介绍
- 分辨率:人脸/人体裁剪图像的宽度和高度必须为
384px
。
- 精度:FP32 / FP16。
- 依赖库:
- 需要安装
mivolo
库,可以使用以下命令进行安装:
pip install git+https://github.com/WildChlamydia/MiVOLO.git
- 同时需要
transformers==4.51.0
和 accelerate==1.8.1
。
代码示例
from transformers import AutoModelForImageClassification, AutoConfig, AutoImageProcessor
import torch
import cv2
import numpy as np
import requests
config = AutoConfig.from_pretrained(
"iitolstykh/mivolo_v2", trust_remote_code=True
)
mivolo_model = AutoModelForImageClassification.from_pretrained(
"iitolstykh/mivolo_v2", trust_remote_code=True, torch_dtype=torch.float16
)
image_processor = AutoImageProcessor.from_pretrained(
"iitolstykh/mivolo_v2", trust_remote_code=True
)
resp = requests.get('https://variety.com/wp-content/uploads/2023/04/MCDNOHA_SP001.jpg')
arr = np.asarray(bytearray(resp.content), dtype=np.uint8)
image = cv2.imdecode(arr, -1)
x1, y1, x2, y2 = [625, 46, 686, 121]
faces_crops = [image[y1:y2, x1:x2]]
x1, y1, x2, y2 = [534, 16, 790, 559]
bodies_crops = [image[y1:y2, x1:x2]]
faces_input = image_processor(images=faces_crops)["pixel_values"]
body_input = image_processor(images=bodies_crops)["pixel_values"]
faces_input = faces_input.to(dtype=mivolo_model.dtype, device=mivolo_model.device)
body_input = body_input.to(dtype=mivolo_model.dtype, device=mivolo_model.device)
output = mivolo_model(faces_input=faces_input, body_input=body_input)
age = output.age_output[0].item()
print(f"年龄: {round(age, 2)}")
id2label = config.gender_id2label
gender = id2label[output.gender_class_idx[0].item()]
gender_prob = output.gender_probs[0].item()
print(f"性别: {gender} [{int(gender_prob * 100)}%]")
模型指标
模型 |
测试数据集 |
年龄准确率 |
性别准确率 |
mivolov2_384x384 (fp16) |
Adience |
70.2 |
97.3 |
MiVOLO V1 (224x224) 架构

📄 引用
🌟 如果您觉得我们的工作有帮助,请考虑引用我们的论文并留下宝贵的星标。
@article{mivolo2023,
Author = {Maksim Kuprashevich and Irina Tolstykh},
Title = {MiVOLO: Multi-input Transformer for Age and Gender Estimation},
Year = {2023},
Eprint = {arXiv:2307.04616},
}
@article{mivolo2024,
Author = {Maksim Kuprashevich and Grigorii Alekseenko and Irina Tolstykh},
Title = {Beyond Specialization: Assessing the Capabilities of MLLMs in Age and Gender Estimation},
Year = {2024},
Eprint = {arXiv:2403.02302},
}
📄 许可证
请查看 此处 获取详细的许可证信息。