PengWeixuanSZU commited on
Commit
951d099
·
verified ·
1 Parent(s): eb5fdd3

Update app.py. Add counter.

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -187,7 +187,8 @@ def process_video(video_file, image_file, positive_prompt, negative_prompt, guid
187
  video_shard=1
188
  elif choice==65:
189
  video_shard=2
190
-
 
191
  pipe=PIPE
192
 
193
  h = 448
@@ -232,10 +233,11 @@ def process_video(video_file, image_file, positive_prompt, negative_prompt, guid
232
  os.makedirs(f"./{target_path}", exist_ok=True)
233
  output_path:str=f"./{target_path}/output_{video_file[-5]}.mp4"
234
  export_to_video(video, output_path, fps=8)
235
- return output_path
236
 
237
 
238
  PIPE=init_pipe()
 
239
 
240
 
241
  with gr.Blocks() as demo:
@@ -262,12 +264,13 @@ with gr.Blocks() as demo:
262
  seed = gr.Slider(minimum=0, maximum=2147483647, step=1, value=0, label="Seed")
263
  guidance_slider = gr.Slider(minimum=1, maximum=10, value=4, label="Guidance")
264
  choice=gr.Radio(choices=[33,65],label="Frame number",value=33)
 
265
  with gr.Column():
266
  video_output = gr.Video(label="Video output")
267
 
268
  with gr.Row():
269
  submit_button = gr.Button("Generate")
270
- submit_button.click(fn=process_video, inputs=[video_input, image_input, positive_prompt, negative_prompt, guidance_slider, seed, choice], outputs=video_output)
271
  with gr.Row():
272
  gr.Examples(
273
  [
@@ -282,7 +285,7 @@ with gr.Blocks() as demo:
282
  ["assets/8.mp4","assets/8_edit.png",get_prompt("assets/8.txt")[0],get_prompt("assets/8.txt")[1],4,0,33]
283
  ],
284
  inputs=[video_input, image_input, positive_prompt, negative_prompt, guidance_slider, seed, choice],
285
- outputs=video_output,
286
  fn=process_video,
287
  cache_examples=False
288
  )
 
187
  video_shard=1
188
  elif choice==65:
189
  video_shard=2
190
+ global counter
191
+ counter+=1
192
  pipe=PIPE
193
 
194
  h = 448
 
233
  os.makedirs(f"./{target_path}", exist_ok=True)
234
  output_path:str=f"./{target_path}/output_{video_file[-5]}.mp4"
235
  export_to_video(video, output_path, fps=8)
236
+ return output_path,counter
237
 
238
 
239
  PIPE=init_pipe()
240
+ counter=0
241
 
242
 
243
  with gr.Blocks() as demo:
 
264
  seed = gr.Slider(minimum=0, maximum=2147483647, step=1, value=0, label="Seed")
265
  guidance_slider = gr.Slider(minimum=1, maximum=10, value=4, label="Guidance")
266
  choice=gr.Radio(choices=[33,65],label="Frame number",value=33)
267
+ counter_output=gr.Textbox(label="User counter",interactive=False)
268
  with gr.Column():
269
  video_output = gr.Video(label="Video output")
270
 
271
  with gr.Row():
272
  submit_button = gr.Button("Generate")
273
+ submit_button.click(fn=process_video, inputs=[video_input, image_input, positive_prompt, negative_prompt, guidance_slider, seed, choice], outputs=[video_output,counter_output])
274
  with gr.Row():
275
  gr.Examples(
276
  [
 
285
  ["assets/8.mp4","assets/8_edit.png",get_prompt("assets/8.txt")[0],get_prompt("assets/8.txt")[1],4,0,33]
286
  ],
287
  inputs=[video_input, image_input, positive_prompt, negative_prompt, guidance_slider, seed, choice],
288
+ outputs=[video_output,counter_output],
289
  fn=process_video,
290
  cache_examples=False
291
  )