File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -419,13 +419,49 @@ class Script(scripts.Script):
419419
420420 def __init__ (self ) -> None :
421421 super ().__init__ ()
422+ #记录无id元素的id
423+ self .new_ids = {}
422424
423425 def title (self ):
424426 return "lightdiffusionflow plugin"
425427
426428 def show (self , is_img2img ):
427429 return scripts .AlwaysVisible
428430
431+ def after_component (self , component , ** kwargs ):
432+ #当前模式
433+ teb_mode = "img2img" if self .is_img2img else "txt2img"
434+ #空id补全方法
435+ def in_zone (dom ,id = "" ):
436+ if dom :
437+ if dom .elem_id :
438+ id += "-" + dom .elem_id
439+ return in_zone (dom .parent ,id )
440+ elif dom .elem_classes and dom .elem_classes [0 ]!= 'gradio-blocks' :
441+ if dom .elem_classes [0 ]== 'gradio-accordion' :
442+ id += '-' + dom .label + "?"
443+ return in_zone (dom .parent ,id )
444+ if re .search ('2img_(textual|hypernetworks|checkpoints|lora)_' ,id ):
445+ return False
446+ else :
447+ id = re .sub (r'\?[^\?]+$|[ \?]' ,'' ,id )
448+ if id in self .new_ids :
449+ self .new_ids [id ]+= 1
450+ else :
451+ self .new_ids [id ]= 1
452+ return id + '-' + str (self .new_ids [id ])
453+
454+ #记录组件
455+ try :
456+ #拉取id
457+ id = component .elem_id
458+ #若没有就重构
459+ if id == None :
460+ id = component .elem_id == in_zone (component .parent ,teb_mode )
461+ Webui_Comps [id ] = component
462+ except BaseException as e :
463+ pass
464+
429465 def ui (self , is_img2img ):
430466 global File_extension
431467
You can’t perform that action at this time.
0 commit comments