Spaces:
Configuration error
Configuration error
File size: 1,408 Bytes
99c376f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import gradio
from modules import script_callbacks, ui_components
from scripts import m2m_hook as patches
elem_ids = []
def fix_elem_id(component, **kwargs):
if "elem_id" not in kwargs:
return None
elem_id = kwargs["elem_id"]
if not elem_id:
return None
if elem_id not in elem_ids:
elem_ids.append(elem_id)
else:
elem_id = elem_id + "_" + str(elem_ids.count(elem_id))
elem_ids.append(elem_id)
return elem_id
def IOComponent_init(self, *args, **kwargs):
elem_id = fix_elem_id(self, **kwargs)
if elem_id:
kwargs.pop("elem_id")
res = original_IOComponent_init(self, elem_id=elem_id, *args, **kwargs)
else:
res = original_IOComponent_init(self, *args, **kwargs)
return res
def InputAccordion_init(self, *args, **kwargs):
elem_id = fix_elem_id(self, **kwargs)
if elem_id:
kwargs.pop("elem_id")
res = original_InputAccordion_init(self, elem_id=elem_id, *args, **kwargs)
else:
res = original_InputAccordion_init(self, *args, **kwargs)
return res
original_IOComponent_init = patches.patch(
__name__,
obj=gradio.components.IOComponent,
field="__init__",
replacement=IOComponent_init,
)
original_InputAccordion_init = patches.patch(
__name__,
obj=ui_components.InputAccordion,
field="__init__",
replacement=InputAccordion_init,
)
|