提交 08c68820 编写于 作者: W w-e-w

gradio 3.41.2 attempt

上级 f0f100e6
......@@ -93,8 +93,8 @@ class PydanticModelGenerator:
d.field: (d.field_type, Field(default=d.field_value, alias=d.field_alias, exclude=d.field_exclude)) for d in self._model_def
}
DynamicModel = create_model(self._model_name, **fields)
DynamicModel.__config__.allow_population_by_field_name = True
DynamicModel.__config__.allow_mutation = True
DynamicModel.model_config['populate_by_name'] = True
DynamicModel.model_config['frozen'] = True
return DynamicModel
StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator(
......
from inspect import signature
from functools import wraps
import gradio as gr
from modules import scripts, ui_tempdir, patches
......@@ -64,10 +66,77 @@ def Blocks_get_config_file(self, *args, **kwargs):
return config
original_IOComponent_init = patches.patch(__name__, obj=gr.components.IOComponent, field="__init__", replacement=IOComponent_init)
def gradio_component_compatibility_layer(component_function):
@wraps(component_function)
def patched_function(*args, **kwargs):
original_signature = signature(component_function).parameters
valid_kwargs = {k: v for k, v in kwargs.items() if k in original_signature}
result = component_function(*args, **valid_kwargs)
return result
return patched_function
sub_events = ['then', 'success']
def gradio_component_events_compatibility_layer(component_function):
@wraps(component_function)
def patched_function(*args, **kwargs):
kwargs['js'] = kwargs.get('js', kwargs.pop('_js', None))
original_signature = signature(component_function).parameters
valid_kwargs = {k: v for k, v in kwargs.items() if k in original_signature}
result = component_function(*args, **valid_kwargs)
for sub_event in sub_events:
component_event_then_function = getattr(result, sub_event, None)
if component_event_then_function:
patched_component_event_then_function = gradio_component_sub_events_compatibility_layer(component_event_then_function)
setattr(result, sub_event, patched_component_event_then_function)
# original_component_event_then_function = patches.patch(f'{__name__}.', obj=result, field='then', replacement=patched_component_event_then_function)
return result
return patched_function
def gradio_component_sub_events_compatibility_layer(component_function):
@wraps(component_function)
def patched_function(*args, **kwargs):
kwargs['js'] = kwargs.get('js', kwargs.pop('_js', None))
original_signature = signature(component_function).parameters
valid_kwargs = {k: v for k, v in kwargs.items() if k in original_signature}
result = component_function(*args, **valid_kwargs)
return result
return patched_function
for component_name in set(gr.components.__all__ + gr.layouts.__all__):
try:
component = getattr(gr, component_name)
component_init = getattr(component, '__init__')
patched_component_init = gradio_component_compatibility_layer(component_init)
original_IOComponent_init = patches.patch(f'{__name__}.{component_name}', obj=component, field="__init__", replacement=patched_component_init)
component_events = set(getattr(component, 'EVENTS'))
for component_event in component_events:
component_event_function = getattr(component, component_event)
patched_component_event_function = gradio_component_events_compatibility_layer(component_event_function)
original_component_event_function = patches.patch(f'{__name__}.{component_name}.{component_event}', obj=component, field=component_event, replacement=patched_component_event_function)
except Exception as e:
print(e)
pass
gr.Box = gr.Group
original_IOComponent_init = patches.patch(__name__, obj=gr.components.base.Component, field="__init__", replacement=IOComponent_init)
original_Block_get_config = patches.patch(__name__, obj=gr.blocks.Block, field="get_config", replacement=Block_get_config)
original_BlockContext_init = patches.patch(__name__, obj=gr.blocks.BlockContext, field="__init__", replacement=BlockContext_init)
original_Blocks_get_config_file = patches.patch(__name__, obj=gr.blocks.Blocks, field="get_config_file", replacement=Blocks_get_config_file)
ui_tempdir.install_ui_tempdir_override()
......@@ -32,8 +32,8 @@ from modules.generation_parameters_copypaste import image_from_url_text
create_setting_component = ui_settings.create_setting_component
warnings.filterwarnings("default" if opts.show_warnings else "ignore", category=UserWarning)
warnings.filterwarnings("default" if opts.show_gradio_deprecation_warnings else "ignore", category=gr.deprecation.GradioDeprecationWarning)
# warnings.filterwarnings("default" if opts.show_warnings else "ignore", category=UserWarning)
# warnings.filterwarnings("default" if opts.show_gradio_deprecation_warnings else "ignore", category=gr.deprecation.GradioDeprecationWarning)
# this is a fix for Windows users. Without it, javascript files will be served with text/html content-type and the browser will not show any UI
mimetypes.init()
......
......@@ -61,7 +61,7 @@ def save_pil_to_file(self, pil_image, dir=None, format="png"):
def install_ui_tempdir_override():
"""override save to file function so that it also writes PNG info"""
gradio.components.IOComponent.pil_to_temp_file = save_pil_to_file
# gradio.components.IOComponent.pil_to_temp_file = save_pil_to_file
def on_tmpdir_changed():
......
......@@ -8,7 +8,7 @@ clean-fid
einops
fastapi>=0.90.1
gfpgan
gradio==3.41.2
gradio==4.7.1
inflection
jsonmerge
kornia
......
......@@ -5,9 +5,9 @@ basicsr==1.4.2
blendmodes==2022
clean-fid==0.1.35
einops==0.4.1
fastapi==0.94.0
fastapi==0.104.1
gfpgan==1.3.8
gradio==3.41.2
gradio==4.7.1
httpcore==0.15
inflection==0.5.1
jsonmerge==1.8.0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册