4848
4949def test_func ():
5050 global extensions_conponents , extensions_id_conponents
51+ global Output_Log
5152 print ("test_func" )
52- # res = re.search(r"(\[[0-9A-Fa-f]{8,10}\])", "control_v11p_sd15_scribble [d4ba51aafd]" )
53- # print(res)
53+ print ( Output_Log )
54+
5455 #from scripts.processor import preprocessor_filters
5556 #print(preprocessor_filters)
5657
57- cn_model_name = "control_v1p_sd15_qrco1de_monster [5e5778cb]"
58-
59- cn_type_list = ['canny' ,'depth' ,'normalmap' ,'openpose' ,'mlsd' ,'lineart_anime' ,'lineart' ,'softedge' ,'scribble' ,
60- 'seg' ,'shuffle' ,'tile' ,'inpaint' ,'ip2p' ,'brightness' ,'illumination' ,'qrcode_monster' ,'qrcode' ,'normalbae' ]
61-
62- type_pattern = "(" + "|" .join (cn_type_list )+ ")"
63- print (type_pattern )
64- res = re .search (type_pattern ,cn_model_name )
65- if (res != None ):
66- print (res .group ())
67-
6858 #print(extensions_id_conponents["dropdown"]["state-ext-control-net-txt2img_0-model"].get_config())
6959
7060 # print(parameters_copypaste.paste_fields)
@@ -150,16 +140,6 @@ def cn_get_model_type(cn_model_name):
150140 if (res != None ):
151141 return res .group ()
152142
153- # #cn_model_name = "control_v1p_sd15_qrcode_monster [5e5778cb]"
154- # res = re.search(r"(\[[0-9A-Fa-f]{8,10}\])", cn_model_name)
155- # if(res != None):
156- # cn_model_hash_val = res.group(1)
157- # cn_model_no_hash = cn_model_name.replace(cn_model_hash_val,"").rstrip().lower()
158- # else:
159- # cn_model_no_hash = cn_model_name.rstrip().lower()
160- # model_type = cn_model_no_hash.split("_")[-1]
161- # print(model_type)
162- # return model_type
163143 return None
164144
165145def set_dropdowns ():
@@ -508,6 +488,9 @@ def fn_import_workflow(workflow_file):
508488 # return tuple(return_vals)
509489 return str (temp_index )#, Output_Log, Output_Log
510490
491+ class config_params (BaseModel ):
492+ config_data :dict
493+
511494class imgs_callback_params (BaseModel ):
512495 id :str
513496 img :str
@@ -529,7 +512,7 @@ def add_api_route(self, path: str, endpoint, **kwargs):
529512 return self .app .add_api_route (self .get_path (path ), endpoint , ** kwargs )
530513
531514 def start (self , _ : gr .Blocks , app : FastAPI ):
532- print ("-----------------state_api start------------------" )
515+ print ("----------------- light_diffusion_flow api start------------------" )
533516
534517 self .app = app
535518 # 读取本地的config.json
@@ -542,6 +525,7 @@ def start(self, _: gr.Blocks, app: FastAPI):
542525 self .add_api_route ('/local/get_ext_list' , self .get_ext_list , methods = ['GET' ])
543526 # 用户设置了新图片 触发回调保存到 workflow_json
544527 self .add_api_route ('/local/imgs_callback' , self .imgs_callback , methods = ['POST' ])
528+ self .add_api_route ('/local/useless_config_filter' , self .useless_config_filter , methods = ['POST' ])
545529 # 刷新页面之后触发
546530 self .add_api_route ('/local/refresh_ui' , self .refresh_ui , methods = ['GET' ])
547531 self .add_api_route ('/local/output_log' , add_output_log , methods = ['GET' ])
@@ -565,6 +549,20 @@ def get_ext_list(self):
565549 pass
566550 return ext_str
567551
552+ def useless_config_filter (self , config :config_params ):
553+ global extensions_id_conponents
554+ new_config = config .config_data
555+ for comp_type in extensions_id_conponents .keys ():
556+ for comp_id in extensions_id_conponents [comp_type ].keys ():
557+ try :
558+ # 筛掉python相关组件的默认值选项
559+ default_val = extensions_id_conponents [comp_type ][comp_id ].get_config ()["value" ]
560+ if (default_val == new_config [comp_id ]):
561+ del new_config [comp_id ]
562+ except KeyError as e :
563+ pass
564+ return new_config
565+
568566 def get_lightdiffusionflow_config (self , onlyimg :bool = False ):
569567 global workflow_json , extensions_id_conponents , extensions_id_conponents_value
570568 temp_json = {}
@@ -963,7 +961,7 @@ def custom_ui(self):
963961 State_Comps ["background_import" ] = gr .File (label = "LightDiffusionFlow File" ,file_count = "single" ,
964962 file_types = [File_extension ],visible = False )
965963 State_Comps ["json2js" ] = gr .Textbox (label = "json2js" ,visible = False )
966- State_Comps ["test_button" ] = gr .Button (value = '测试' ,elem_id = 'test_button' ,visible = True )
964+ State_Comps ["test_button" ] = gr .Button (value = '测试' ,elem_id = 'test_button' ,visible = False )
967965 State_Comps ["refresh_log" ] = gr .Button (value = '刷新日志' ,elem_id = 'img2img_invisible_refresh_log' ,visible = False )
968966 State_Comps ["set_dropdowns" ] = gr .Button (value = '设置部分参数' ,elem_id = 'lightdiffusionflow_set_dropdowns' ,visible = False )
969967 State_Comps ["set_js_params" ] = gr .Button (value = '设置剩下的js参数' ,elem_id = 'lightdiffusionflow_set_js_params' ,visible = False )
0 commit comments