sk61tc4j53obiq commited on
Commit
7beb357
·
verified ·
1 Parent(s): 865220b

Move rent time from constant to gradio

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -31,7 +31,7 @@ from transformers import WhisperModel
31
 
32
  import spaces
33
 
34
- SPACES_MAX_DURATION = 5 * 60 # 5 minutes
35
 
36
  if os.getenv('SYSTEM') == 'spaces':
37
  subprocess.run(["bash", "install.sh"])
@@ -189,11 +189,14 @@ def fast_check_ffmpeg():
189
  except:
190
  return False
191
 
 
 
 
192
 
193
- @spaces.GPU(duration=SPACES_MAX_DURATION)
194
  @torch.no_grad()
195
  def inference(audio_path, video_path, bbox_shift, extra_margin=10, parsing_mode="jaw",
196
- left_cheek_width=90, right_cheek_width=90, progress=gr.Progress(track_tqdm=True)):
197
  # Set default parameters, aligned with inference.py
198
  args_dict = {
199
  "result_dir": './results/output',
@@ -519,6 +522,7 @@ with gr.Blocks(css=css) as demo:
519
  parsing_mode = gr.Radio(label="Parsing Mode", choices=["jaw", "raw"], value="jaw")
520
  left_cheek_width = gr.Slider(label="Left Cheek Width", minimum=20, maximum=160, value=90, step=5)
521
  right_cheek_width = gr.Slider(label="Right Cheek Width", minimum=20, maximum=160, value=90, step=5)
 
522
  bbox_shift_scale = gr.Textbox(label="'left_cheek_width' and 'right_cheek_width' parameters determine the range of left and right cheeks editing when parsing model is 'jaw'. The 'extra_margin' parameter determines the movement range of the jaw. Users can freely adjust these three parameters to obtain better inpainting results.")
523
 
524
  with gr.Row():
@@ -541,7 +545,8 @@ with gr.Blocks(css=css) as demo:
541
  extra_margin,
542
  parsing_mode,
543
  left_cheek_width,
544
- right_cheek_width
 
545
  ],
546
  outputs=[out1,bbox_shift_scale]
547
  )
 
31
 
32
  import spaces
33
 
34
+ DEFAULT_RENT_TIME = 300
35
 
36
  if os.getenv('SYSTEM') == 'spaces':
37
  subprocess.run(["bash", "install.sh"])
 
189
  except:
190
  return False
191
 
192
+ def get_duration():
193
+ step_duration = 3.75
194
+ return steps * step_duration
195
 
196
+ @spaces.GPU(duration=get_duration)
197
  @torch.no_grad()
198
  def inference(audio_path, video_path, bbox_shift, extra_margin=10, parsing_mode="jaw",
199
+ left_cheek_width=90, right_cheek_width=90, rent_time=DEFAULT_RENT_TIME, progress=gr.Progress(track_tqdm=True)):
200
  # Set default parameters, aligned with inference.py
201
  args_dict = {
202
  "result_dir": './results/output',
 
522
  parsing_mode = gr.Radio(label="Parsing Mode", choices=["jaw", "raw"], value="jaw")
523
  left_cheek_width = gr.Slider(label="Left Cheek Width", minimum=20, maximum=160, value=90, step=5)
524
  right_cheek_width = gr.Slider(label="Right Cheek Width", minimum=20, maximum=160, value=90, step=5)
525
+ rent_time = gr.Slider(label="Available/maximum rent time", minimum=1, maximum=1500, value=DEFAULT_RENT_TIME, step=1)
526
  bbox_shift_scale = gr.Textbox(label="'left_cheek_width' and 'right_cheek_width' parameters determine the range of left and right cheeks editing when parsing model is 'jaw'. The 'extra_margin' parameter determines the movement range of the jaw. Users can freely adjust these three parameters to obtain better inpainting results.")
527
 
528
  with gr.Row():
 
545
  extra_margin,
546
  parsing_mode,
547
  left_cheek_width,
548
+ right_cheek_width,
549
+ rent_time
550
  ],
551
  outputs=[out1,bbox_shift_scale]
552
  )