Update app.py
Browse files
app.py
CHANGED
|
@@ -74,38 +74,24 @@ def infer(text):
|
|
| 74 |
raise ValueError("Generated motion data is empty")
|
| 75 |
|
| 76 |
gif_bytes = draw_to_batch([motion_data], [text], None)
|
| 77 |
-
|
| 78 |
-
# Ensure the directory exists in the current working directory
|
| 79 |
-
dir_path = "animation"
|
| 80 |
-
if not os.path.exists(dir_path):
|
| 81 |
-
os.makedirs(dir_path)
|
| 82 |
-
|
| 83 |
-
persistent_gif_path = os.path.join(dir_path, "animation.gif")
|
| 84 |
-
with open(persistent_gif_path, "wb") as f:
|
| 85 |
-
f.write(gif_bytes)
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
raise ValueError("Generated GIF is empty")
|
| 91 |
-
if not os.path.exists(persistent_gif_path):
|
| 92 |
-
print(f"Error: GIF not saved to {persistent_gif_path}")
|
| 93 |
-
else:
|
| 94 |
-
print(f"GIF saved successfully to {persistent_gif_path}")
|
| 95 |
|
| 96 |
-
return
|
| 97 |
|
| 98 |
with gr.Blocks(css=".container { max-width: 800px; margin: auto; }") as demo:
|
| 99 |
with gr.Column():
|
| 100 |
-
gr.Markdown("## 3D Human Motion
|
| 101 |
text_input = gr.Textbox(label="Enter the human action to generate", placeholder="Enter text description for the action here...")
|
| 102 |
-
|
| 103 |
submit_button = gr.Button("Generate Motion")
|
| 104 |
|
| 105 |
submit_button.click(
|
| 106 |
fn=infer,
|
| 107 |
inputs=[text_input],
|
| 108 |
-
outputs=[
|
| 109 |
)
|
| 110 |
|
| 111 |
if __name__ == "__main__":
|
|
|
|
| 74 |
raise ValueError("Generated motion data is empty")
|
| 75 |
|
| 76 |
gif_bytes = draw_to_batch([motion_data], [text], None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
# Encode the GIF bytes to a base64 string
|
| 79 |
+
gif_base64 = base64.b64encode(gif_bytes).decode('ascii')
|
| 80 |
+
gif_html = f'<img src="data:image/gif;base64,{gif_base64}" />'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
return gif_html
|
| 83 |
|
| 84 |
with gr.Blocks(css=".container { max-width: 800px; margin: auto; }") as demo:
|
| 85 |
with gr.Column():
|
| 86 |
+
gr.Markdown("## 3D Human Motion Generation")
|
| 87 |
text_input = gr.Textbox(label="Enter the human action to generate", placeholder="Enter text description for the action here...")
|
| 88 |
+
output_html = gr.HTML(label="Generated Human Motion")
|
| 89 |
submit_button = gr.Button("Generate Motion")
|
| 90 |
|
| 91 |
submit_button.click(
|
| 92 |
fn=infer,
|
| 93 |
inputs=[text_input],
|
| 94 |
+
outputs=[output_html]
|
| 95 |
)
|
| 96 |
|
| 97 |
if __name__ == "__main__":
|