Desident commited on
Commit
d475781
·
verified ·
1 Parent(s): 58c341a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -21,7 +21,7 @@ if not os.path.exists(os.path.join(checkpoint_dir, "liveportrait_onnx")):
21
  repo_id="warmshao/FasterLivePortrait",
22
  local_dir=checkpoint_dir
23
  )
24
- print("Всі моделі успішно завантажено!")
25
 
26
  def load_description(fp):
27
  if os.path.exists(fp):
@@ -74,8 +74,7 @@ retargeting_input_image = gr.Image(type="filepath")
74
  output_image = gr.Image(format="png", type="numpy")
75
  output_image_paste_back = gr.Image(format="png", type="numpy")
76
 
77
-
78
- with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Plus Jakarta Sans")]), js=js_func) as demo:
79
  gr.HTML(load_description(title_md))
80
 
81
  gr.Markdown(load_description("assets/gradio/gradio_description_upload.md"))
@@ -90,7 +89,8 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Plus Jakarta San
90
  with gr.Accordion(open=True, label="Source Video"):
91
  source_video_input = gr.Video()
92
 
93
- tab_selection = gr.Textbox(visible=False)
 
94
  tab_image.select(lambda: "Image", None, tab_selection)
95
  tab_video.select(lambda: "Video", None, tab_selection)
96
  with gr.Accordion(open=True, label="Cropping Options for Source Image or Video"):
@@ -165,7 +165,7 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Plus Jakarta San
165
  step=0.02)
166
  cfg_scale = gr.Number(value=4.0, label="cfg_scale", minimum=0.0, maximum=10.0, step=0.5)
167
  flag_remap_input = gr.Checkbox(value=True, label="paste-back")
168
- animation_region = gr.Radio(["exp", "pose", "lip", "eyes", "all"], value="all",
169
  label="animation region")
170
  flag_video_editing_head_rotation = gr.Checkbox(value=False, label="relative head rotation (v2v)")
171
  driving_smooth_observation_variance = gr.Number(value=1e-7, label="motion smooth strength (v2v)",
@@ -269,6 +269,8 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Plus Jakarta San
269
  )
270
 
271
  if __name__ == '__main__':
 
 
272
  demo.launch(
273
  server_port=7860,
274
  share=False,
 
21
  repo_id="warmshao/FasterLivePortrait",
22
  local_dir=checkpoint_dir
23
  )
24
+ print("Всі特色 моделі успішно завантажено!")
25
 
26
  def load_description(fp):
27
  if os.path.exists(fp):
 
74
  output_image = gr.Image(format="png", type="numpy")
75
  output_image_paste_back = gr.Image(format="png", type="numpy")
76
 
77
+ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Plus Jakarta Sans")])) as demo:
 
78
  gr.HTML(load_description(title_md))
79
 
80
  gr.Markdown(load_description("assets/gradio/gradio_description_upload.md"))
 
89
  with gr.Accordion(open=True, label="Source Video"):
90
  source_video_input = gr.Video()
91
 
92
+ # ФІКС 1: Задаємо дефолтне значення "Image", щоб бекенд не падав, якщо користувач не клікав по табах
93
+ tab_selection = gr.Textbox(value="Image", visible=False)
94
  tab_image.select(lambda: "Image", None, tab_selection)
95
  tab_video.select(lambda: "Video", None, tab_selection)
96
  with gr.Accordion(open=True, label="Cropping Options for Source Image or Video"):
 
165
  step=0.02)
166
  cfg_scale = gr.Number(value=4.0, label="cfg_scale", minimum=0.0, maximum=10.0, step=0.5)
167
  flag_remap_input = gr.Checkbox(value=True, label="paste-back")
168
+ animation_region = gr.Radio(["all", "exp", "pose", "lip", "eyes"], value="all",
169
  label="animation region")
170
  flag_video_editing_head_rotation = gr.Checkbox(value=False, label="relative head rotation (v2v)")
171
  driving_smooth_observation_variance = gr.Number(value=1e-7, label="motion smooth strength (v2v)",
 
269
  )
270
 
271
  if __name__ == '__main__':
272
+ # ФІКС 2: АКТИВУЄМО ВНУТРІШНЮ ЧЕРГУ GRADIO (Обов'язково для хмарних Spaces під довгі завдання)
273
+ demo.queue()
274
  demo.launch(
275
  server_port=7860,
276
  share=False,