rsax commited on
Commit
949770f
·
verified ·
1 Parent(s): e03fed8

Update visualization/plot_3d_global.py

Browse files
Files changed (1) hide show
  1. visualization/plot_3d_global.py +48 -24
visualization/plot_3d_global.py CHANGED
@@ -93,35 +93,59 @@ def plot_3d_motion(args, figsize=(10, 10), fps=120, radius=4):
93
  ax.set_xticklabels([])
94
  ax.set_yticklabels([])
95
  ax.set_zticklabels([])
96
-
97
- if out_name is not None:
98
- plt.savefig(out_name, dpi=96)
99
- plt.close()
100
-
101
- else:
102
- io_buf = io.BytesIO()
103
- fig.savefig(io_buf, format='png', dpi=96)
104
- io_buf.seek(0)
105
- img = Image.open(io_buf)
106
- img_array = np.array(img)
107
- io_buf.close()
108
- plt.close()
109
- return img_array
110
-
111
  out = [update(i) for i in range(frame_number)]
112
  out = np.stack(out, axis=0)
113
-
114
  gif_bytes = io.BytesIO()
115
  imageio.mimsave(gif_bytes, out, format='GIF', fps=fps)
116
  gif_bytes.seek(0)
117
  return gif_bytes.getvalue()
118
 
119
-
120
  def draw_to_batch(smpl_joints_batch, title_batch=None, outname=None):
121
- batch_size = len(smpl_joints_batch)
122
- out = []
123
- for i in range(batch_size):
124
- gif_data = plot_3d_motion([smpl_joints_batch[i], None, title_batch[i] if title_batch is not None else None])
125
- out.append(gif_data)
126
- print(f"Generated GIF for batch {i+1}/{batch_size}, size: {len(gif_data)} bytes")
127
- return out[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  ax.set_xticklabels([])
94
  ax.set_yticklabels([])
95
  ax.set_zticklabels([])
96
+
97
+ io_buf = io.BytesIO()
98
+ fig.savefig(io_buf, format='png', dpi=96)
99
+ io_buf.seek(0)
100
+ img = Image.open(io_buf)
101
+ img_array = np.array(img)
102
+ io_buf.close()
103
+ plt.close()
104
+
105
+ return img_array
106
+
 
 
 
 
107
  out = [update(i) for i in range(frame_number)]
108
  out = np.stack(out, axis=0)
109
+
110
  gif_bytes = io.BytesIO()
111
  imageio.mimsave(gif_bytes, out, format='GIF', fps=fps)
112
  gif_bytes.seek(0)
113
  return gif_bytes.getvalue()
114
 
 
115
  def draw_to_batch(smpl_joints_batch, title_batch=None, outname=None):
116
+ gif_data = plot_3d_motion([smpl_joints_batch[0], None, title_batch[0] if title_batch is not None else None])
117
+ return gif_data
118
+
119
+
120
+
121
+ # if out_name is not None:
122
+ # plt.savefig(out_name, dpi=96)
123
+ # plt.close()
124
+
125
+ # else:
126
+ # io_buf = io.BytesIO()
127
+ # fig.savefig(io_buf, format='png', dpi=96)
128
+ # io_buf.seek(0)
129
+ # img = Image.open(io_buf)
130
+ # img_array = np.array(img)
131
+ # io_buf.close()
132
+ # plt.close()
133
+ # return img_array
134
+
135
+ # out = [update(i) for i in range(frame_number)]
136
+ # out = np.stack(out, axis=0)
137
+
138
+ # gif_bytes = io.BytesIO()
139
+ # imageio.mimsave(gif_bytes, out, format='GIF', fps=fps)
140
+ # gif_bytes.seek(0)
141
+ # return gif_bytes.getvalue()
142
+
143
+
144
+ # def draw_to_batch(smpl_joints_batch, title_batch=None, outname=None):
145
+ # batch_size = len(smpl_joints_batch)
146
+ # out = []
147
+ # for i in range(batch_size):
148
+ # gif_data = plot_3d_motion([smpl_joints_batch[i], None, title_batch[i] if title_batch is not None else None])
149
+ # out.append(gif_data)
150
+ # print(f"Generated GIF for batch {i+1}/{batch_size}, size: {len(gif_data)} bytes")
151
+ # return out[0]