Spaces:
Runtime error
Runtime error
Commit
β’
e804e78
1
Parent(s):
c405fec
Update styles
Browse files- app.py +17 -9
- assets/css/custom.css +9 -8
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import os
|
|
|
2 |
os.environ["PYOPENGL_PLATFORM"] = "egl"
|
3 |
os.environ["MESA_GL_VERSION_OVERRIDE"] = "4.1"
|
4 |
os.system('pip install /home/user/app/pyrender')
|
5 |
os.system('pip install eventlet')
|
6 |
|
7 |
-
|
8 |
import gradio as gr
|
9 |
import random
|
10 |
import torch
|
@@ -28,7 +28,6 @@ import librosa
|
|
28 |
from huggingface_hub import snapshot_download
|
29 |
import eventlet
|
30 |
|
31 |
-
|
32 |
# Load model
|
33 |
cfg = parse_args(phase="webui") # parse config file
|
34 |
cfg.FOLDER = 'cache'
|
@@ -129,20 +128,20 @@ def render_motion(data, feats, method='fast'):
|
|
129 |
aroot = data[[0], 0]
|
130 |
aroot[:, 1] = -aroot[:, 1]
|
131 |
params = dict(pred_shape=np.zeros([1, 10]),
|
132 |
-
|
133 |
-
|
134 |
render.init_renderer([shape[0], shape[1], 3], params)
|
135 |
for i in range(data.shape[0]):
|
136 |
renderImg = render.render(i)
|
137 |
vid.append(renderImg)
|
138 |
-
|
139 |
out = np.stack(vid, axis=0)
|
140 |
output_gif_path = output_mp4_path[:-4] + '.gif'
|
141 |
imageio.mimwrite(output_gif_path, out, duration=50)
|
142 |
out_video = mp.VideoFileClip(output_gif_path)
|
143 |
out_video.write_videofile(output_mp4_path)
|
144 |
del out, render
|
145 |
-
|
146 |
elif method == 'fast':
|
147 |
output_gif_path = output_mp4_path[:-4] + '.gif'
|
148 |
if len(data.shape) == 3:
|
@@ -315,7 +314,8 @@ def bot(history, motion_uploaded, data_stored, method):
|
|
315 |
history[-1][1] += character
|
316 |
time.sleep(0.02)
|
317 |
yield history, motion_uploaded, data_stored
|
318 |
-
|
|
|
319 |
def bot_example(history, responses):
|
320 |
history = history + responses
|
321 |
return history
|
@@ -366,6 +366,14 @@ with gr.Blocks(css=customCSS) as demo:
|
|
366 |
video_fname="example0_blender.mp4")),
|
367 |
(None, "π Follow the examples and try yourself!"),
|
368 |
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
|
370 |
t2m_examples = gr.State([
|
371 |
(None,
|
@@ -501,7 +509,7 @@ with gr.Blocks(css=customCSS) as demo:
|
|
501 |
elem_id="mGPT",
|
502 |
height=600,
|
503 |
label="MotionGPT",
|
504 |
-
avatar_images=(
|
505 |
("assets/images/avatar_bot.jpg")),
|
506 |
bubble_full_width=False)
|
507 |
|
@@ -571,7 +579,7 @@ with gr.Blocks(css=customCSS) as demo:
|
|
571 |
# [chatbot, motion_uploaded, data_stored],
|
572 |
# queue=False)
|
573 |
|
574 |
-
instruct_msg = instruct_eg.click(bot_example, [chatbot,
|
575 |
[chatbot],
|
576 |
queue=False)
|
577 |
t2m_eg_msg = t2m_eg.click(bot_example, [chatbot, t2m_examples], [chatbot],
|
|
|
1 |
import os
|
2 |
+
|
3 |
os.environ["PYOPENGL_PLATFORM"] = "egl"
|
4 |
os.environ["MESA_GL_VERSION_OVERRIDE"] = "4.1"
|
5 |
os.system('pip install /home/user/app/pyrender')
|
6 |
os.system('pip install eventlet')
|
7 |
|
|
|
8 |
import gradio as gr
|
9 |
import random
|
10 |
import torch
|
|
|
28 |
from huggingface_hub import snapshot_download
|
29 |
import eventlet
|
30 |
|
|
|
31 |
# Load model
|
32 |
cfg = parse_args(phase="webui") # parse config file
|
33 |
cfg.FOLDER = 'cache'
|
|
|
128 |
aroot = data[[0], 0]
|
129 |
aroot[:, 1] = -aroot[:, 1]
|
130 |
params = dict(pred_shape=np.zeros([1, 10]),
|
131 |
+
pred_root=aroot,
|
132 |
+
pred_pose=pose)
|
133 |
render.init_renderer([shape[0], shape[1], 3], params)
|
134 |
for i in range(data.shape[0]):
|
135 |
renderImg = render.render(i)
|
136 |
vid.append(renderImg)
|
137 |
+
|
138 |
out = np.stack(vid, axis=0)
|
139 |
output_gif_path = output_mp4_path[:-4] + '.gif'
|
140 |
imageio.mimwrite(output_gif_path, out, duration=50)
|
141 |
out_video = mp.VideoFileClip(output_gif_path)
|
142 |
out_video.write_videofile(output_mp4_path)
|
143 |
del out, render
|
144 |
+
|
145 |
elif method == 'fast':
|
146 |
output_gif_path = output_mp4_path[:-4] + '.gif'
|
147 |
if len(data.shape) == 3:
|
|
|
314 |
history[-1][1] += character
|
315 |
time.sleep(0.02)
|
316 |
yield history, motion_uploaded, data_stored
|
317 |
+
|
318 |
+
|
319 |
def bot_example(history, responses):
|
320 |
history = history + responses
|
321 |
return history
|
|
|
366 |
video_fname="example0_blender.mp4")),
|
367 |
(None, "π Follow the examples and try yourself!"),
|
368 |
])
|
369 |
+
chat_instruct_sum = gr.State([(None, '''
|
370 |
+
π Hi, I'm MotionGPT! I can generate realistic human motion from text, or generate text from motion.
|
371 |
+
|
372 |
+
1. You can chat with me in pure text like generating human motion following your descriptions.
|
373 |
+
2. After generation, you can click the button in the top right of generation human motion result to download the human motion video or feature stored in .npy format.
|
374 |
+
3. With the human motion feature file downloaded or got from dataset, you are able to ask me to translate it!
|
375 |
+
4. Of course, you can also purely chat with me and let me give you human motion in text, here are some examples!
|
376 |
+
''')] + chat_instruct.value[-7:])
|
377 |
|
378 |
t2m_examples = gr.State([
|
379 |
(None,
|
|
|
509 |
elem_id="mGPT",
|
510 |
height=600,
|
511 |
label="MotionGPT",
|
512 |
+
avatar_images=(None,
|
513 |
("assets/images/avatar_bot.jpg")),
|
514 |
bubble_full_width=False)
|
515 |
|
|
|
579 |
# [chatbot, motion_uploaded, data_stored],
|
580 |
# queue=False)
|
581 |
|
582 |
+
instruct_msg = instruct_eg.click(bot_example, [chatbot, chat_instruct_sum],
|
583 |
[chatbot],
|
584 |
queue=False)
|
585 |
t2m_eg_msg = t2m_eg.click(bot_example, [chatbot, t2m_examples], [chatbot],
|
assets/css/custom.css
CHANGED
@@ -41,19 +41,20 @@
|
|
41 |
|
42 |
[class*='message'] {
|
43 |
border: none;
|
44 |
-
font-size: var(--text-xl) !important;
|
45 |
-
line-height: var(--line-xl) !important;
|
46 |
}
|
47 |
-
|
48 |
-
|
|
|
49 |
width: auto !important;
|
50 |
-
border-bottom-left-radius: 0 !important;
|
51 |
}
|
52 |
[data-testid='user'] {
|
53 |
-
max-width:
|
54 |
width: auto !important;
|
55 |
-
border-bottom-right-radius: 0 !important;
|
56 |
-
}
|
57 |
|
58 |
/* Text & Video */
|
59 |
#method {
|
|
|
41 |
|
42 |
[class*='message'] {
|
43 |
border: none;
|
44 |
+
/* font-size: var(--text-xl) !important;
|
45 |
+
line-height: var(--line-xl) !important; */
|
46 |
}
|
47 |
+
|
48 |
+
[data-testid='bot'] {
|
49 |
+
max-width: 70%;
|
50 |
width: auto !important;
|
51 |
+
/* border-bottom-left-radius: 0 !important; */
|
52 |
}
|
53 |
[data-testid='user'] {
|
54 |
+
max-width: 70%;
|
55 |
width: auto !important;
|
56 |
+
/* border-bottom-right-radius: 0 !important; */
|
57 |
+
}
|
58 |
|
59 |
/* Text & Video */
|
60 |
#method {
|