基于HRN的text-to-3D head模型
基于HRN的text-to-3D head模型,结合了文生图stable diffusion模型和头部重建模型HRN ,以文本为输入,可生成高质量3D头部。
prompt: a clown with red nose.
prompt: a girl with freckles and blue eyes.
三维视觉系列模型
HRN人脸重建 | HRN头部重建 |
模型描述
该text-to-head模型包含了text-to-image以及head reconstruction两个部分,首先利用sd+controlnet进行文本引导的、姿态可控的人脸图像生成,而后利用HRN算法重建出3D头部,从而实现文生3D头部的功能。
期望模型使用方式以及适用范围
使用方式:
- 输入文本描述(目前仅支持英文),返回对应符合文本描述的3D模型(.obj文件+纹理贴图)。
模型参数:
hair_tex: pipeline参数,可在configuration.json中修改,或者在pipeline初始化中传入,如:
pipeline(Tasks.text_to_head, model='damo/cv_HRN_text-to-head', model_revision='v0.1', hair_tex=True))
当hair_tex为True时(默认),将输出带头发的纹理,如以上第一个示例。
当hair_tex为False时,将输出光头的纹理,如以上第二个示例.
使用范围:
- 请输入人物描述词,当输入描述词与人无关时,可能会失败。
- 由于HRN是基于真实人脸的重建模型,所以当目标与真实人头越相近时,效果越好。
目标场景:
- 影视、娱乐等。
如何使用
本模型基于pytorch进行训练和推理,在ModelScope框架上,提供输入描述词,即可以通过简单的Pipeline调用来使用text-to-head模型。
代码范例
import os
import cv2
from modelscope.models.cv.face_reconstruction.utils import write_obj
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
def save_results(result, save_root):
os.makedirs(save_root, exist_ok=True)
# export obj and texture
mesh = result[OutputKeys.OUTPUT]['mesh']
texture_map = result[OutputKeys.OUTPUT_IMG]
mesh['texture_map'] = texture_map
write_obj(os.path.join(save_root, 'text_to_head_result.obj'), mesh)
print(f'Output written to {os.path.abspath(save_root)}')
text_to_head = pipeline(Tasks.text_to_head, model='damo/cv_HRN_text-to-head', model_revision='v0.1')
result = text_to_head('a clown with red nose')
save_results(result, './text_to_head_results')
预处理
- 对输入的prompt进行优化,加入后缀描述词,反向描述词等。
后处理
- 将顶点坐标、三角面片、贴图等数据转化为obj等模型文件。
引用
如果你觉得这个该模型对有所帮助,请考虑引用下面的相关的论文:
@inproceedings{lei2023hierarchical,
title={A Hierarchical Representation Network for Accurate and Detailed Face Reconstruction from In-The-Wild Images},
author={Lei, Biwen and Ren, Jianqiang and Feng, Mengyang and Cui, Miaomiao and Xie, Xuansong},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={394--403},
year={2023}
}
评论