Skip to content

Commit 92b1f24

Browse files
authored
Merge pull request #26 from Tencent/dev
linux下创建文件夹失败问题修复。
2 parents 86d0551 + 87dd91d commit 92b1f24

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

scripts/state_api.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
import launch
2525

2626
from scripts import lightdiffusionflow_version, lightdiffusionflow_config
27-
from scripts.lightdiffusionflow_config import OutputPrompt, Flow_Save_mode, Auto_Fix_Params, LoRAs_In_Use
2827
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
2934

3035
# current_path = os.path.abspath(os.path.dirname(__file__))
3136
# sys.path.append(os.path.join(current_path,"lib"))
@@ -46,10 +51,23 @@
4651
img2img_script_container = None
4752

4853
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}'失败!请手动创建该文件夹,以保证插件功能正常运行。")
5371

5472
local_flow_list = []
5573
Need_Preload = False
@@ -194,9 +212,12 @@ def SearchingCheckPointByHashFromCivitai(hash:str):
194212
def refresh_local_flows(*inputs):
195213
print("refresh_local_flows")
196214
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 = []
200221
# print(inputs)
201222
# print(local_flow_list)
202223
ret = []
@@ -1333,9 +1354,12 @@ def custom_ui(self):
13331354
save_mode = " (only ControlNet)"
13341355

13351356
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 = []
13391363

13401364
with gr.Accordion('LightDiffusionFlow '+lightdiffusionflow_version.lightdiffusionflow_version + save_mode, open=True, visible=True, elem_id=cur_mode+'_lightdiffusionflow'):
13411365

scripts/state_settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import gradio as gr
22
import modules.shared as shared
33
from modules import scripts
4-
from scripts.lightdiffusionflow_config import OutputPrompt
4+
from scripts import lightdiffusionflow_config
5+
#from scripts.lightdiffusionflow_config import OutputPrompt
6+
OutputPrompt = lightdiffusionflow_config.OutputPrompt
57

68
def on_ui_settings():
79

0 commit comments

Comments
 (0)