栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

STAR可视化代码(pytorch) —— hellostar.py

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

STAR可视化代码(pytorch) —— hellostar.py

# with MPG or you get the right to use the computer program from someone who is authorized to grant you that right.
# Any use of the computer program without a valid license is prohibited and liable to prosecution.
# Contact: ps-license@tuebingen.mpg.de
#
#
# If you use this code in a research publication please consider citing the following:
#
# STAR: Sparse Trained  Articulated Human Body Regressor 
#
#
# Code Developed by:
# Ahmed A. A. Osman
from star.pytorch.star_model import STAR           # load model's parameters and return v_posed  
                                                   #  & transformed joints
import numpy as np
from numpy import newaxis
import pickle
import os
import torch

# beta contorls male model
betas = np.array([
            np.array([ 2.25176191, 2.25176191, 0.46747496, 3.89178988,
                      2.20098416, 0.26102114, 2.25176191, 0.55708514,
                      2.25176191, 2.25176191])])
num_betas=10
batch_size=1
#m = STAR(gender='male',num_betas=num_betas)

# Zero pose with female model
star = STAR(gender='female')
poses = torch.cuda.FloatTensor(np.zeros((batch_size,72)))
betas = torch.cuda.FloatTensor(betas)

trans = torch.cuda.FloatTensor(np.zeros((batch_size,3)))
verts = star.forward(poses, betas,trans)            # result model
verts=verts.tolist()                                # change data's structure from tensor to list 
faces = star.f                                      # faces is list so no need to change
shaped = verts.v_shaped[-1, :, :]                   # result model's v_posed

## Write to an .obj file
outmesh_path = '/home/xxw/Downloads/STAR-master/star/pytorch/hello_smpl.obj'
with open( outmesh_path, 'w') as fp:
    for v in range(len(verts[0])):                                           
        fp.write( 'v %f %f %fn' % (verts[0][v][0], verts[0][v][1], verts[0][v][2]) )

    for f in range(len(faces)): # Faces are 1-based, not 0-based in obj files
        fp.write( 'f %d %d %dn' %  (faces[f][0]+1, faces[f][1]+1, faces[f][2]+1) )

## Print message
print ('..Output mesh saved to: ', outmesh_path)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/689041.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号