From aa13346b524d2f9b235c09928b3d27b505bd4fc2 Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Fri, 3 Feb 2023 11:40:55 +0000 Subject: [PATCH] add ploting --- main.py | 4 +++- requirements.txt | 3 ++- utils.py | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 10cee62..6e2595e 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ os.environ["CUDA_VISIBLE_DEVICES"] = '6' import numpy as np from smpl_tf import SMPL +from utils import plot_mesh if __name__ == '__main__': smpl_tf : SMPL = SMPL('model_files') @@ -11,7 +12,8 @@ if __name__ == '__main__': betas = np.zeros((1, 11), dtype=np.float32) poses = np.zeros((1, 72), dtype=np.float32) R = smpl_tf.run_rodrigues(poses) - posed = smpl_tf.run(R, betas) + posed, _, _ = smpl_tf.run(R, betas) + plot_mesh(posed[0].numpy(), smpl_tf.f).show() pass \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f6e9b77..87f2d09 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ numpy scipy -tensorflow \ No newline at end of file +tensorflow +plotly \ No newline at end of file diff --git a/utils.py b/utils.py index e69de29..7b47685 100644 --- a/utils.py +++ b/utils.py @@ -0,0 +1,25 @@ +import plotly.graph_objects as go + + +def plot_mesh(verts, faces): + fig = go.Figure() + + fig.add_trace(go.Mesh3d( + x=verts[:,0], + y=verts[:,2], + z=verts[:,1], + i = faces[:,0], + j = faces[:,1], + k = faces[:,2], + text="", + ),) + + fig.update_layout(scene_aspectmode='manual', scene_aspectratio=dict(x=1, y=1, z=1)) + helper = dict(xaxis = dict(range=[-1,1], showbackground=False, showticklabels=False, showaxeslabels=False, showspikes=False, visible=False), + yaxis = dict(range=[-1,1], showbackground=False, showticklabels=False, showaxeslabels=False, showspikes=False, visible=False), + zaxis = dict(range=[-1,1], showbackground=False, showticklabels=False, showaxeslabels=False, showspikes=False, visible=False),) + fig.update_layout(scene = helper) + + fig.update_layout(margin=dict(l=0, r=0, b=0, t=0, pad=0)) + + return fig \ No newline at end of file