3 Star 7 Fork 2

Gitee 极速下载/prnet

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/YadiraF/PRNet
克隆/下载
run_basics.py 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
YadiraF 提交于 2018-07-19 18:12 . add training, specify texture size
import numpy as np
import os
from glob import glob
import scipy.io as sio
from skimage.io import imread, imsave
from time import time
from api import PRN
from utils.write import write_obj_with_colors
# ---- init PRN
os.environ['CUDA_VISIBLE_DEVICES'] = '0' # GPU number, -1 for CPU
prn = PRN(is_dlib = False)
# ------------- load data
image_folder = 'TestImages/AFLW2000/'
save_folder = 'TestImages/AFLW2000_results'
if not os.path.exists(save_folder):
os.mkdir(save_folder)
types = ('*.jpg', '*.png')
image_path_list= []
for files in types:
image_path_list.extend(glob(os.path.join(image_folder, files)))
total_num = len(image_path_list)
for i, image_path in enumerate(image_path_list):
# read image
image = imread(image_path)
# the core: regress position map
if 'AFLW2000' in image_path:
mat_path = image_path.replace('jpg', 'mat')
info = sio.loadmat(mat_path)
kpt = info['pt3d_68']
pos = prn.process(image, kpt) # kpt information is only used for detecting face and cropping image
else:
pos = prn.process(image) # use dlib to detect face
# -- Basic Applications
# get landmarks
kpt = prn.get_landmarks(pos)
# 3D vertices
vertices = prn.get_vertices(pos)
# corresponding colors
colors = prn.get_colors(image, vertices)
# -- save
name = image_path.strip().split('/')[-1][:-4]
np.savetxt(os.path.join(save_folder, name + '.txt'), kpt)
write_obj_with_colors(os.path.join(save_folder, name + '.obj'), vertices, prn.triangles, colors) #save 3d face(can open with meshlab)
sio.savemat(os.path.join(save_folder, name + '_mesh.mat'), {'vertices': vertices, 'colors': colors, 'triangles': prn.triangles})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/prnet.git
git@gitee.com:mirrors/prnet.git
mirrors
prnet
prnet
master

搜索帮助