From 79fd17ee6332fafeee9f7fac8e150721dcefdb94 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Tue, 22 Aug 2023 08:18:01 +0300 Subject: [PATCH] remove unneeded example_inputs from gradio config --- modules/gradio_extensons.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/gradio_extensons.py b/modules/gradio_extensons.py index 77c34c8ba..e6b6835ad 100644 --- a/modules/gradio_extensons.py +++ b/modules/gradio_extensons.py @@ -1,6 +1,7 @@ import gradio as gr -from modules import scripts, ui_tempdir +from modules import scripts, ui_tempdir, patches + def add_classes_to_gradio_component(comp): """ @@ -40,6 +41,8 @@ def Block_get_config(self): if webui_tooltip: config["webui_tooltip"] = webui_tooltip + config.pop('example_inputs', None) + return config @@ -51,12 +54,20 @@ def BlockContext_init(self, *args, **kwargs): return res -original_IOComponent_init = gr.components.IOComponent.__init__ -original_Block_get_config = gr.blocks.Block.get_config -original_BlockContext_init = gr.blocks.BlockContext.__init__ +def Blocks_get_config_file(self, *args, **kwargs): + config = original_Blocks_get_config_file(self, *args, **kwargs) + + for comp_config in config["components"]: + if "example_inputs" in comp_config: + comp_config["example_inputs"] = {"serialized": []} + + return config + + +original_IOComponent_init = patches.patch(__name__, obj=gr.components.IOComponent, 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) -gr.components.IOComponent.__init__ = IOComponent_init -gr.blocks.Block.get_config = Block_get_config -gr.blocks.BlockContext.__init__ = BlockContext_init ui_tempdir.install_ui_tempdir_override()