@@ -85,45 +85,12 @@ def set_lightdiffusionflow_file():
8585再用json2js的onchange事件触发js来点击隐藏按钮开始触发设置图片的事件队列。
8686'''
8787def on_after_component (component , ** kwargs ):
88-
89- #当前模式
90- teb_mode = "img2img" if self .is_img2img else "txt2img"
91- #空id补全方法
92- def in_zone (dom ,id = "" ):
93- if dom :
94- if dom .elem_id :
95- id += "-" + dom .elem_id
96- return in_zone (dom .parent ,id )
97- elif dom .elem_classes and dom .elem_classes [0 ]!= 'gradio-blocks' :
98- if dom .elem_classes [0 ]== 'gradio-accordion' :
99- id += '-' + dom .label + "?"
100- return in_zone (dom .parent ,id )
101- if re .search ('2img_(textual|hypernetworks|checkpoints|lora)_' ,id ):
102- return False
103- else :
104- id = re .sub (r'\?[^\?]+$|[ \?]' ,'' ,id )
105- if id in self .new_ids :
106- self .new_ids [id ]+= 1
107- else :
108- self .new_ids [id ]= 1
109- return id + '-' + str (self .new_ids [id ])
110-
111- #记录组件
88+
11289 try :
113- #拉取id
114- id = component .elem_id
115- #若没有就重构
116- if id == None :
117- component .elem_id = kwargs ["elem_id" ]= in_zone (component .parent ,teb_mode )
118- Webui_Comps [kwargs ["elem_id" ]] = component
90+ if (Webui_Comps .get (kwargs ["elem_id" ], None ) == None ):
91+ Webui_Comps [kwargs ["elem_id" ]] = component
11992 except BaseException as e :
12093 pass
121-
122- #try:
123- #if(Webui_Comps.get(kwargs["elem_id"], None) == None):
124- #Webui_Comps[kwargs["elem_id"]] = component
125- #except BaseException as e:
126- #pass
12794
12895 if (isinstance (component , gr .Button ) and kwargs ["elem_id" ] == "change_checkpoint" ): # 加载到最后一个组件了
12996 #print("LightDiffusionFlow绑定按钮")
0 commit comments