24
24
from tqdm import tqdm
25
25
26
26
import folder_paths
27
- file_path = os .path .join (os .path .dirname (folder_paths .__file__ ), 'comfy_extras/nodes_clip_sdxl.py' )
28
- module_name = "nodes_clip_sdxl"
29
- spec = importlib .util .spec_from_file_location (module_name , file_path )
30
- module = importlib .util .module_from_spec (spec )
31
- sys .modules [module_name ] = module
32
- spec .loader .exec_module (module )
33
- from nodes_clip_sdxl import CLIPTextEncodeSDXL , CLIPTextEncodeSDXLRefiner
34
- file_path = os .path .join (os .path .dirname (folder_paths .__file__ ), 'comfy_extras/nodes_upscale_model.py' )
35
- module_name = "nodes_upscale_model"
36
- spec = importlib .util .spec_from_file_location (module_name , file_path )
37
- module = importlib .util .module_from_spec (spec )
38
- sys .modules [module_name ] = module
39
- spec .loader .exec_module (module )
27
+ from comfy_extras .nodes_clip_sdxl import CLIPTextEncodeSDXL , CLIPTextEncodeSDXLRefiner
40
28
import comfy_extras
41
- from nodes_upscale_model import UpscaleModelLoader , ImageUpscaleWithModel
29
+ from comfy_extras . nodes_upscale_model import UpscaleModelLoader , ImageUpscaleWithModel
42
30
from comfy .model_management import soft_empty_cache , free_memory , get_torch_device , current_loaded_models , load_model_gpu
43
31
from nodes import LoraLoader , ConditioningAverage , common_ksampler , ImageScale , ImageScaleBy , VAEEncode , VAEDecode
44
32
import comfy .utils
@@ -142,6 +130,9 @@ def read_ratios():
142
130
ratio_dict = data ['ratios' ]
143
131
# user_styles.json
144
132
user_styles_path = os .path .join (folder_paths .get_user_directory (), 'user_ratios.json' )
133
+ # backwards compatibility with pre paths update to comfy
134
+ if not os .path .isfile (user_styles_path ):
135
+ user_styles_path = os .path .join (os .path .dirname (folder_paths .__file__ ), 'user_ratios.json' )
145
136
# check if file exists
146
137
if os .path .isfile (user_styles_path ):
147
138
# read json and update ratio_dict
@@ -161,6 +152,9 @@ def read_ratio_presets():
161
152
ratio_preset_dict = data ['ratio_presets' ]
162
153
# user_ratio_presets.json
163
154
user_ratio_presets_path = os .path .join (folder_paths .get_user_directory (), 'user_ratio_presets.json' )
155
+ # backwards compatibility with pre paths update to comfy
156
+ if not os .path .isfile (user_ratio_presets_path ):
157
+ user_ratio_presets_path = os .path .join (os .path .dirname (folder_paths .__file__ ), 'user_ratio_presets.json' )
164
158
# check if file exists
165
159
if os .path .isfile (user_ratio_presets_path ):
166
160
# read json and update ratio_dict
@@ -199,6 +193,9 @@ def read_styles():
199
193
neg_style [style ] = data ['styles' ][style ]['negative' ]
200
194
# user_styles.json
201
195
user_styles_path = os .path .join (folder_paths .get_user_directory (), 'user_styles.json' )
196
+ # backwards compatibility with pre paths update to comfy
197
+ if not os .path .isfile (user_styles_path ):
198
+ user_styles_path = os .path .join (os .path .dirname (folder_paths .__file__ ), 'user_styles.json' )
202
199
# check if file exists
203
200
if os .path .isfile (user_styles_path ):
204
201
# read json and update pos_style and neg_style
@@ -223,6 +220,9 @@ def read_styles():
223
220
def find_and_replace_wildcards (prompt , offset_seed , debug = False ):
224
221
# wildcards use the __file_name__ syntax with optional |word_to_find
225
222
wildcard_path = os .path .join (folder_paths .get_user_directory (), 'wildcards' )
223
+ # backwards compatibility with pre paths update to comfy
224
+ if not os .path .isdir (wildcard_path ):
225
+ wildcard_path = os .path .join (os .path .dirname (folder_paths .__file__ ), 'wildcards' )
226
226
wildcard_regex = r'((\d+)\$\$)?__(!|\+|-|\*)?((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__'
227
227
# r'(\[(\d+)\$\$)?__((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__\]?'
228
228
match_strings = []
0 commit comments