jiuface commited on
Commit
985fbf6
·
verified ·
1 Parent(s): 7271af9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -99,7 +99,7 @@ def _calculate_new_dimensions_wan(pil_image, mod_val, calculation_max_area,
99
  return new_h, new_w
100
 
101
 
102
- def upload_image_to_r2(video_file, account_id, access_key, secret_key, bucket_name):
103
  with calculateDuration("Upload video"):
104
  connectionUrl = f"https://{account_id}.r2.cloudflarestorage.com"
105
  s3 = boto3.client(
@@ -130,11 +130,25 @@ def handle_image_upload_for_dims_wan(uploaded_pil_image, current_h_val, current_
130
  gr.Warning("Error attempting to calculate new dimensions")
131
  return gr.update(value=DEFAULT_H_SLIDER_VALUE), gr.update(value=DEFAULT_W_SLIDER_VALUE)
132
 
133
- def get_duration(input_image, prompt, height, width,
134
- negative_prompt, duration_seconds,
135
- guidance_scale, steps,
136
- seed, randomize_seed,
137
- progress):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  if steps > 4 and duration_seconds > 2:
139
  return 90
140
  elif steps > 4 or duration_seconds > 2:
@@ -142,6 +156,7 @@ def get_duration(input_image, prompt, height, width,
142
  else:
143
  return 60
144
 
 
145
  @spaces.GPU(duration=get_duration)
146
  def generate_video(image_url,
147
  prompt,
@@ -215,7 +230,7 @@ with gr.Blocks() as demo:
215
  height_input = gr.Slider(minimum=SLIDER_MIN_H, maximum=SLIDER_MAX_H, step=MOD_VALUE, value=DEFAULT_H_SLIDER_VALUE, label=f"Output Height (multiple of {MOD_VALUE})")
216
  width_input = gr.Slider(minimum=SLIDER_MIN_W, maximum=SLIDER_MAX_W, step=MOD_VALUE, value=DEFAULT_W_SLIDER_VALUE, label=f"Output Width (multiple of {MOD_VALUE})")
217
  steps_slider = gr.Slider(minimum=1, maximum=30, step=1, value=4, label="Inference Steps")
218
- guidance_scale_input = gr.Slider(minimum=0.0, maximum=20.0, step=0.5, value=1.0, label="Guidance Scale", visible=False)
219
 
220
  with gr.Accordion("R2 Settings", open=False):
221
  upload_to_r2 = gr.Checkbox(label="Upload to R2", value=False)
 
99
  return new_h, new_w
100
 
101
 
102
+ def upload_video_to_r2(video_file, account_id, access_key, secret_key, bucket_name):
103
  with calculateDuration("Upload video"):
104
  connectionUrl = f"https://{account_id}.r2.cloudflarestorage.com"
105
  s3 = boto3.client(
 
130
  gr.Warning("Error attempting to calculate new dimensions")
131
  return gr.update(value=DEFAULT_H_SLIDER_VALUE), gr.update(value=DEFAULT_W_SLIDER_VALUE)
132
 
133
+ def get_duration(
134
+ image_url,
135
+ prompt,
136
+ height,
137
+ width,
138
+ negative_prompt,
139
+ duration_seconds,
140
+ guidance_scale,
141
+ steps,
142
+ seed,
143
+ randomize_seed,
144
+ upload_to_r2,
145
+ account_id,
146
+ access_key,
147
+ secret_key,
148
+ bucket,
149
+ progress=gr.Progress(track_tqdm=True)
150
+ ):
151
+ # 保持逻辑不变
152
  if steps > 4 and duration_seconds > 2:
153
  return 90
154
  elif steps > 4 or duration_seconds > 2:
 
156
  else:
157
  return 60
158
 
159
+
160
  @spaces.GPU(duration=get_duration)
161
  def generate_video(image_url,
162
  prompt,
 
230
  height_input = gr.Slider(minimum=SLIDER_MIN_H, maximum=SLIDER_MAX_H, step=MOD_VALUE, value=DEFAULT_H_SLIDER_VALUE, label=f"Output Height (multiple of {MOD_VALUE})")
231
  width_input = gr.Slider(minimum=SLIDER_MIN_W, maximum=SLIDER_MAX_W, step=MOD_VALUE, value=DEFAULT_W_SLIDER_VALUE, label=f"Output Width (multiple of {MOD_VALUE})")
232
  steps_slider = gr.Slider(minimum=1, maximum=30, step=1, value=4, label="Inference Steps")
233
+ guidance_scale_input = gr.Slider(minimum=0.0, maximum=20.0, step=0.5, value=1.0, label="Guidance Scale", visible=True)
234
 
235
  with gr.Accordion("R2 Settings", open=False):
236
  upload_to_r2 = gr.Checkbox(label="Upload to R2", value=False)