| 
24 | 24 | import launch  | 
25 | 25 | 
 
  | 
26 | 26 | from scripts import lightdiffusionflow_version, lightdiffusionflow_config  | 
27 |  | -from scripts.lightdiffusionflow_config import OutputPrompt, Flow_Save_mode, Auto_Fix_Params, LoRAs_In_Use  | 
28 | 27 | import scripts.lightdiffusionflow_config as lf_config  | 
 | 28 | +# from scripts.lightdiffusionflow_config import OutputPrompt, Flow_Save_mode, Auto_Fix_Params, LoRAs_In_Use #   | 
 | 29 | + | 
 | 30 | +Flow_Save_mode = lf_config.Flow_Save_mode  | 
 | 31 | +Auto_Fix_Params = lf_config.Auto_Fix_Params  | 
 | 32 | +LoRAs_In_Use = lf_config.LoRAs_In_Use  | 
 | 33 | +OutputPrompt = lf_config.OutputPrompt  | 
29 | 34 | 
 
  | 
30 | 35 | # current_path = os.path.abspath(os.path.dirname(__file__))  | 
31 | 36 | # sys.path.append(os.path.join(current_path,"lib"))  | 
 | 
46 | 51 | img2img_script_container = None  | 
47 | 52 | 
 
  | 
48 | 53 | local_flows_path = "models/LightDiffusionFlow"  | 
49 |  | -flows_path = os.path.join(data_path, local_flows_path)   | 
50 |  | -flows_path = flows_path.replace("/","\\")  | 
51 |  | -if(not os.path.isdir(flows_path)):  | 
52 |  | -  os.mkdir(flows_path)  | 
 | 54 | +if True:  | 
 | 55 | +  flows_path = os.path.join(data_path, local_flows_path)   | 
 | 56 | +  flows_path = flows_path.replace("\\","/") # linux下反斜杠有问题  | 
 | 57 | +  print(flows_path)  | 
 | 58 | +  try:  | 
 | 59 | +    if(not os.path.exists(flows_path)):  | 
 | 60 | +      os.makedirs(flows_path)  | 
 | 61 | +      if(os.path.exists(flows_path)):  | 
 | 62 | +        print(f"本地文件夹'{flows_path}'创建成功!")  | 
 | 63 | +      else:  | 
 | 64 | +        print(f"本地文件夹'{flows_path}'创建失败!")  | 
 | 65 | +  except BaseException as e:  | 
 | 66 | +    pass  | 
 | 67 | + | 
 | 68 | +  if(not os.path.exists(flows_path)):  | 
 | 69 | +    print(f"The creation of the folder '{local_flows_path}' has failed! Please create this folder manually to ensure the proper functioning of the extension.")  | 
 | 70 | +    print(f"创建文件夹'{local_flows_path}'失败!请手动创建该文件夹,以保证插件功能正常运行。")  | 
53 | 71 | 
 
  | 
54 | 72 | local_flow_list = []  | 
55 | 73 | Need_Preload = False  | 
@@ -194,9 +212,12 @@ def SearchingCheckPointByHashFromCivitai(hash:str):  | 
194 | 212 | def refresh_local_flows(*inputs):  | 
195 | 213 |   print("refresh_local_flows")  | 
196 | 214 |   global local_flow_list,local_flows_path  | 
197 |  | -  flows_path = os.path.join(data_path, local_flows_path)   | 
198 |  | -  local_flow_list = [f for f in os.listdir(flows_path) if os.path.isfile(  | 
199 |  | -      os.path.join(flows_path, f)) and os.path.splitext(f)[-1] == '.flow']  | 
 | 215 | +  try:  | 
 | 216 | +    flows_path = os.path.join(data_path, local_flows_path)   | 
 | 217 | +    local_flow_list = [f for f in os.listdir(flows_path) if os.path.isfile(  | 
 | 218 | +        os.path.join(flows_path, f)) and os.path.splitext(f)[-1] == '.flow']  | 
 | 219 | +  except:  | 
 | 220 | +    local_flow_list = []  | 
200 | 221 |   # print(inputs)  | 
201 | 222 |   # print(local_flow_list)  | 
202 | 223 |   ret = []  | 
@@ -1333,9 +1354,12 @@ def custom_ui(self):  | 
1333 | 1354 |       save_mode = " (only ControlNet)"  | 
1334 | 1355 | 
 
  | 
1335 | 1356 |     global local_flow_list,local_flows_path  | 
1336 |  | -    flows_path = os.path.join(data_path, local_flows_path)   | 
1337 |  | -    local_flow_list = [f for f in os.listdir(flows_path) if os.path.isfile(  | 
1338 |  | -        os.path.join(flows_path, f)) and os.path.splitext(f)[-1] == '.flow']  | 
 | 1357 | +    try:  | 
 | 1358 | +      flows_path = os.path.join(data_path, local_flows_path)   | 
 | 1359 | +      local_flow_list = [f for f in os.listdir(flows_path) if os.path.isfile(  | 
 | 1360 | +          os.path.join(flows_path, f)) and os.path.splitext(f)[-1] == '.flow']  | 
 | 1361 | +    except:  | 
 | 1362 | +      local_flow_list = []  | 
1339 | 1363 | 
 
  | 
1340 | 1364 |     with gr.Accordion('LightDiffusionFlow '+lightdiffusionflow_version.lightdiffusionflow_version + save_mode, open=True, visible=True, elem_id=cur_mode+'_lightdiffusionflow'):  | 
1341 | 1365 | 
 
  | 
 | 
0 commit comments