Spaces:
Paused
Paused
return frame filepaths
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ with gr.Blocks() as demo:
|
|
| 22 |
submit_btn = gr.Button(value="Generate")
|
| 23 |
with gr.Column():
|
| 24 |
animation = gr.Video(label="Result")
|
| 25 |
-
frames = gr.Gallery(type="
|
| 26 |
|
| 27 |
submit_btn.click(
|
| 28 |
run_app, inputs=[char_imgs, mocap, tr_steps, inf_steps, fps, remove_bg, resize_inputs], outputs=[animation, frames]
|
|
|
|
| 22 |
submit_btn = gr.Button(value="Generate")
|
| 23 |
with gr.Column():
|
| 24 |
animation = gr.Video(label="Result")
|
| 25 |
+
frames = gr.Gallery(type="filepath", label="Frames", format="png")
|
| 26 |
|
| 27 |
submit_btn.click(
|
| 28 |
run_app, inputs=[char_imgs, mocap, tr_steps, inf_steps, fps, remove_bg, resize_inputs], outputs=[animation, frames]
|
main.py
CHANGED
|
@@ -84,6 +84,7 @@ max_batch_size = 8
|
|
| 84 |
|
| 85 |
def save_temp_imgs(imgs):
|
| 86 |
os.makedirs('temp', exist_ok=True)
|
|
|
|
| 87 |
|
| 88 |
for img in imgs:
|
| 89 |
|
|
@@ -100,11 +101,16 @@ def save_temp_imgs(imgs):
|
|
| 100 |
|
| 101 |
# Print the server's response
|
| 102 |
print("Status Code:", response.status_code)
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
except requests.exceptions.RequestException as e:
|
| 106 |
print(f"An error occurred: {e}")
|
| 107 |
|
|
|
|
|
|
|
| 108 |
|
| 109 |
# Pose detection ==============================================================================================
|
| 110 |
|
|
@@ -1082,7 +1088,7 @@ def run_inference(images, video_path, train_steps=100, inference_steps=10, fps=1
|
|
| 1082 |
target_poses, in_pose = prepare_inputs_inference(in_img, video_path, fps, dwpose, 'target', is_app)
|
| 1083 |
|
| 1084 |
results = inference(modelId, in_img, in_pose, target_poses, inference_steps, None, vae, unet, image_encoder_p, is_app)
|
| 1085 |
-
save_temp_imgs(results)
|
| 1086 |
|
| 1087 |
if should_gen_vid:
|
| 1088 |
if debug:
|
|
@@ -1092,7 +1098,7 @@ def run_inference(images, video_path, train_steps=100, inference_steps=10, fps=1
|
|
| 1092 |
|
| 1093 |
print("Done!")
|
| 1094 |
|
| 1095 |
-
return out_vid+'.webm',
|
| 1096 |
|
| 1097 |
|
| 1098 |
def run_app(images, video_path, train_steps=100, inference_steps=10, fps=12, bg_remove=False, resize_inputs=True):
|
|
|
|
| 84 |
|
| 85 |
def save_temp_imgs(imgs):
|
| 86 |
os.makedirs('temp', exist_ok=True)
|
| 87 |
+
results = []
|
| 88 |
|
| 89 |
for img in imgs:
|
| 90 |
|
|
|
|
| 101 |
|
| 102 |
# Print the server's response
|
| 103 |
print("Status Code:", response.status_code)
|
| 104 |
+
|
| 105 |
+
data = response.json()
|
| 106 |
+
print("Response JSON:", data)
|
| 107 |
+
results.append(data['data']['url'])
|
| 108 |
|
| 109 |
except requests.exceptions.RequestException as e:
|
| 110 |
print(f"An error occurred: {e}")
|
| 111 |
|
| 112 |
+
return results
|
| 113 |
+
|
| 114 |
|
| 115 |
# Pose detection ==============================================================================================
|
| 116 |
|
|
|
|
| 1088 |
target_poses, in_pose = prepare_inputs_inference(in_img, video_path, fps, dwpose, 'target', is_app)
|
| 1089 |
|
| 1090 |
results = inference(modelId, in_img, in_pose, target_poses, inference_steps, None, vae, unet, image_encoder_p, is_app)
|
| 1091 |
+
urls = save_temp_imgs(results)
|
| 1092 |
|
| 1093 |
if should_gen_vid:
|
| 1094 |
if debug:
|
|
|
|
| 1098 |
|
| 1099 |
print("Done!")
|
| 1100 |
|
| 1101 |
+
return out_vid+'.webm', urls
|
| 1102 |
|
| 1103 |
|
| 1104 |
def run_app(images, video_path, train_steps=100, inference_steps=10, fps=12, bg_remove=False, resize_inputs=True):
|