acmyu commited on
Commit
4c37470
·
1 Parent(s): ce41078

return local output url

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. main.py +20 -5
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="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]
 
22
  submit_btn = gr.Button(value="Generate")
23
  with gr.Column():
24
  animation = gr.Video(label="Result")
25
+ frames = gr.Gallery(type="pil", 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
@@ -60,7 +60,7 @@ from numba import cuda
60
  import requests
61
  import uuid
62
 
63
- from huggingface_hub import hf_hub_download
64
 
65
 
66
  # Inputs ===================================================================================================
@@ -86,11 +86,16 @@ def save_temp_imgs(imgs):
86
  os.makedirs('temp', exist_ok=True)
87
  results = []
88
 
89
- for img in imgs:
 
 
 
90
 
91
- img_name = 'temp/'+str(uuid.uuid4())+'.png'
 
92
  img.save(img_name)
93
 
 
94
  url = 'https://tmpfiles.org/api/v1/upload'
95
 
96
  try:
@@ -108,6 +113,16 @@ def save_temp_imgs(imgs):
108
 
109
  except requests.exceptions.RequestException as e:
110
  print(f"An error occurred: {e}")
 
 
 
 
 
 
 
 
 
 
111
 
112
  return results
113
 
@@ -1088,7 +1103,7 @@ def run_inference(images, video_path, train_steps=100, inference_steps=10, fps=1
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,7 +1113,7 @@ def run_inference(images, video_path, train_steps=100, inference_steps=10, fps=1
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):
 
60
  import requests
61
  import uuid
62
 
63
+ from huggingface_hub import hf_hub_download, HfApi
64
 
65
 
66
  # Inputs ===================================================================================================
 
86
  os.makedirs('temp', exist_ok=True)
87
  results = []
88
 
89
+ api = HfApi()
90
+
91
+
92
+ for i, img in enumerate(imgs):
93
 
94
+ #img_name = 'temp/'+str(uuid.uuid4())+'.png'
95
+ img_name = 'temp/'+str(i)+'.png'
96
  img.save(img_name)
97
 
98
+ """
99
  url = 'https://tmpfiles.org/api/v1/upload'
100
 
101
  try:
 
113
 
114
  except requests.exceptions.RequestException as e:
115
  print(f"An error occurred: {e}")
116
+ """
117
+
118
+ results.append('https://huggingface.co/datasets/acmyu/KeyframesAIFiles/resolve/main/'+img_name)
119
+
120
+ api.upload_file(
121
+ path_or_fileobj='temp',
122
+ path_in_repo='temp',
123
+ repo_id="acmyu/KeyframesAIFiles",
124
+ repo_type="dataset",
125
+ )
126
 
127
  return results
128
 
 
1103
  target_poses, in_pose = prepare_inputs_inference(in_img, video_path, fps, dwpose, 'target', is_app)
1104
 
1105
  results = inference(modelId, in_img, in_pose, target_poses, inference_steps, None, vae, unet, image_encoder_p, is_app)
1106
+ #urls = save_temp_imgs(results)
1107
 
1108
  if should_gen_vid:
1109
  if debug:
 
1113
 
1114
  print("Done!")
1115
 
1116
+ return out_vid+'.webm', results
1117
 
1118
 
1119
  def run_app(images, video_path, train_steps=100, inference_steps=10, fps=12, bg_remove=False, resize_inputs=True):