rsax commited on
Commit
509ef71
·
verified ·
1 Parent(s): 5673fea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -73,6 +73,7 @@ def generate_motion(text, vqvae_model, transformer_model):
73
  return pred_xyz.cpu().numpy().reshape(-1, 22, 3)
74
 
75
  def infer(text):
 
76
  try:
77
  motion_data = generate_motion(text, vqvae_model, transformer_model)
78
  if motion_data.size == 0:
@@ -84,11 +85,13 @@ def infer(text):
84
  try:
85
  gif_data = draw_to_batch([motion_data], [text], None)
86
  if gif_data:
87
- with tempfile.NamedTemporaryFile(delete=False, suffix=".gif") as temp_file:
88
- temp_file.write(gif_data)
89
- temp_file_path = temp_file.name
90
- print("GIF successfully saved to temporary file.")
91
- return temp_file_path
 
 
92
  else:
93
  print("Failed to generate GIF data.")
94
  return "Error generating GIF. Please try again."
@@ -96,11 +99,12 @@ def infer(text):
96
  print(f"Error generating GIF: {str(e)}")
97
  return "Error generating GIF. Please try again."
98
 
99
- with gr.Blocks(css=".container { max-width: 800px; margin: auto; }") as demo:
 
100
  with gr.Column(elem_id="col-container"):
101
  gr.Markdown("## 3D Human Motion Generation")
102
  with gr.Row():
103
- text_input = gr.Textbox(label="Enter the human action to generate", placeholder="Enter text description for the action here...", show_label=False, max_lines=1, container=False)
104
  submit_button = gr.Button("Generate Motion")
105
  output_image = gr.Image(label="Generated Human Motion", type="filepath", show_label=False)
106
 
@@ -109,6 +113,6 @@ with gr.Blocks(css=".container { max-width: 800px; margin: auto; }") as demo:
109
  inputs=[text_input],
110
  outputs=[output_image]
111
  )
112
-
113
  if __name__ == "__main__":
114
  demo.launch()
 
73
  return pred_xyz.cpu().numpy().reshape(-1, 22, 3)
74
 
75
  def infer(text):
76
+ print("Received text:", text) # Debug: Confirming that the text input is correctly received
77
  try:
78
  motion_data = generate_motion(text, vqvae_model, transformer_model)
79
  if motion_data.size == 0:
 
85
  try:
86
  gif_data = draw_to_batch([motion_data], [text], None)
87
  if gif_data:
88
+ # Save the GIF to a permanent file rather than a temporary file for debugging
89
+ gif_filename = "output.gif"
90
+ gif_path = os.path.join(tempfile.gettempdir(), gif_filename)
91
+ with open(gif_path, "wb") as gif_file:
92
+ gif_file.write(gif_data)
93
+ print("GIF successfully saved to:", gif_path) # Debug: Check the exact path of the saved GIF
94
+ return gif_path
95
  else:
96
  print("Failed to generate GIF data.")
97
  return "Error generating GIF. Please try again."
 
99
  print(f"Error generating GIF: {str(e)}")
100
  return "Error generating GIF. Please try again."
101
 
102
+ css = ".container { max-width: 800px; margin: auto; }"
103
+ with gr.Blocks(css=css) as demo:
104
  with gr.Column(elem_id="col-container"):
105
  gr.Markdown("## 3D Human Motion Generation")
106
  with gr.Row():
107
+ text_input = gr.Textbox(label="Enter the human action to generate", placeholder="Enter text description for the action here...", show_label=True)
108
  submit_button = gr.Button("Generate Motion")
109
  output_image = gr.Image(label="Generated Human Motion", type="filepath", show_label=False)
110
 
 
113
  inputs=[text_input],
114
  outputs=[output_image]
115
  )
116
+
117
  if __name__ == "__main__":
118
  demo.launch()