Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,6 +51,7 @@ import math
|
|
51 |
# from PIL import Image
|
52 |
import hashlib
|
53 |
import gradio as gr
|
|
|
54 |
|
55 |
## load clip model and datasets
|
56 |
is_cuda = torch.cuda.is_available()
|
@@ -222,8 +223,10 @@ def render(motions, device_id=0, name='test_vis'):
|
|
222 |
|
223 |
out = np.stack(vid, axis=0)
|
224 |
imageio.mimwrite(f'output/results.gif', out, fps=20)
|
|
|
|
|
225 |
del out, vertices
|
226 |
-
return f'output/results.
|
227 |
|
228 |
def predict(clip_text, method='fast'):
|
229 |
gc.collect()
|
@@ -239,7 +242,9 @@ def predict(clip_text, method='fast'):
|
|
239 |
if method == 'fast':
|
240 |
xyz = pred_xyz.reshape(1, -1, 22, 3)
|
241 |
pose_vis = plot_3d.draw_to_batch(xyz.detach().cpu().numpy(), title_batch=None, outname=[f'output/results.gif'])
|
242 |
-
|
|
|
|
|
243 |
elif method == 'slow':
|
244 |
output_path = render(pred_xyz.detach().cpu().numpy().squeeze(axis=0), device_id=0, name=output_name)
|
245 |
return output_path
|
|
|
51 |
# from PIL import Image
|
52 |
import hashlib
|
53 |
import gradio as gr
|
54 |
+
import moviepy.editor as mp
|
55 |
|
56 |
## load clip model and datasets
|
57 |
is_cuda = torch.cuda.is_available()
|
|
|
223 |
|
224 |
out = np.stack(vid, axis=0)
|
225 |
imageio.mimwrite(f'output/results.gif', out, fps=20)
|
226 |
+
clip = mp.VideoFileClip(f'output/results.gif')
|
227 |
+
clip.write_videofile("output/results.mp4")
|
228 |
del out, vertices
|
229 |
+
return f'output/results.mp4'
|
230 |
|
231 |
def predict(clip_text, method='fast'):
|
232 |
gc.collect()
|
|
|
242 |
if method == 'fast':
|
243 |
xyz = pred_xyz.reshape(1, -1, 22, 3)
|
244 |
pose_vis = plot_3d.draw_to_batch(xyz.detach().cpu().numpy(), title_batch=None, outname=[f'output/results.gif'])
|
245 |
+
clip = mp.VideoFileClip("output/results.gif")
|
246 |
+
clip.write_videofile("output/results.mp4")
|
247 |
+
return f'output/results.mp4'
|
248 |
elif method == 'slow':
|
249 |
output_path = render(pred_xyz.detach().cpu().numpy().squeeze(axis=0), device_id=0, name=output_name)
|
250 |
return output_path
|