FIX: Gradio4 "update" deprecation

Issues: #507 #496 #491
This commit is contained in:
Евгений Гурьев | Eugene Gourieff | 古仁 2024-08-19 15:06:39 +07:00
parent 613b7d74ea
commit 4493fd7133
4 changed files with 59 additions and 27 deletions

View File

@ -2,7 +2,7 @@
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_EN.png?raw=true" alt="logo" width="180px"/>
![Version](https://img.shields.io/badge/version-0.7.1_alpha1-lightgreen?style=for-the-badge&labelColor=darkgreen)
![Version](https://img.shields.io/badge/version-0.7.1_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen)
<a href="https://boosty.to/artgourieff" target="_blank">
<img src="https://lovemet.ru/www/boosty.jpg" width="108" alt="Support Me on Boosty"/>

View File

@ -2,7 +2,7 @@
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_RU.png?raw=true" alt="logo" width="180px"/>
![Version](https://img.shields.io/badge/версия-0.7.1_alpha1-lightgreen?style=for-the-badge&labelColor=darkgreen)
![Version](https://img.shields.io/badge/версия-0.7.1_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen)
<a href="https://boosty.to/artgourieff" target="_blank">
<img src="https://lovemet.ru/www/boosty.jpg" width="108" alt="Поддержать проект на Boosty"/>

View File

@ -11,9 +11,14 @@ from modules import shared
# SAVE_ORIGINAL: bool = False
def update_fm_list(selected: str):
return gr.Dropdown.update(
value=selected, choices=get_model_names(get_facemodels)
)
try: # GR3.x
return gr.Dropdown.update(
value=selected, choices=get_model_names(get_facemodels)
)
except: # GR4.x
return gr.Dropdown(
value=selected, choices=get_model_names(get_facemodels)
)
# TAB MAIN
def show(is_img2img: bool, show_br: bool = True, **msgs):
@ -24,29 +29,56 @@ def show(is_img2img: bool, show_br: bool = True, **msgs):
if evt.index == 2:
# if SAVE_ORIGINAL != selected:
# SAVE_ORIGINAL = selected
return {
control_col_1: gr.Column.update(visible=False),
control_col_2: gr.Column.update(visible=False),
control_col_3: gr.Column.update(visible=True),
# save_original: gr.Checkbox.update(value=False,visible=False),
imgs_hash_clear: gr.Button.update(visible=True)
}
try: # GR3.x
return {
control_col_1: gr.Column.update(visible=False),
control_col_2: gr.Column.update(visible=False),
control_col_3: gr.Column.update(visible=True),
# save_original: gr.Checkbox.update(value=False,visible=False),
imgs_hash_clear: gr.Button.update(visible=True)
}
except: # GR4.x
return {
control_col_1: gr.Column(visible=False),
control_col_2: gr.Column(visible=False),
control_col_3: gr.Column(visible=True),
# save_original: gr.Checkbox.update(value=False,visible=False),
imgs_hash_clear: gr.Button(visible=True)
}
if evt.index == 0:
return {
control_col_1: gr.Column.update(visible=True),
control_col_2: gr.Column.update(visible=False),
control_col_3: gr.Column.update(visible=False),
# save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button.update(visible=False)
}
try: # GR3.x
return {
control_col_1: gr.Column.update(visible=True),
control_col_2: gr.Column.update(visible=False),
control_col_3: gr.Column.update(visible=False),
# save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button.update(visible=False)
}
except: # GR4.x
return {
control_col_1: gr.Column(visible=True),
control_col_2: gr.Column(visible=False),
control_col_3: gr.Column(visible=False),
# save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button(visible=False)
}
if evt.index == 1:
return {
control_col_1: gr.Column.update(visible=False),
control_col_2: gr.Column.update(visible=True),
control_col_3: gr.Column.update(visible=False),
# save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button.update(visible=False)
}
try: # GR3.x
return {
control_col_1: gr.Column.update(visible=False),
control_col_2: gr.Column.update(visible=True),
control_col_3: gr.Column.update(visible=False),
# save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button.update(visible=False)
}
except: # GR4.x
return {
control_col_1: gr.Column(visible=False),
control_col_2: gr.Column(visible=True),
control_col_3: gr.Column(visible=False),
# save_original: gr.Checkbox.update(value=SAVE_ORIGINAL,visible=show_br),
imgs_hash_clear: gr.Button(visible=False)
}
progressbar_area = gr.Markdown("")
with gr.Tab("Main"):

View File

@ -1,5 +1,5 @@
app_title = "ReActor"
version_flag = "v0.7.1-a1"
version_flag = "v0.7.1-a2"
from scripts.reactor_logger import logger, get_Run, set_Run
from scripts.reactor_globals import DEVICE