2424from tqdm import tqdm
2525
2626import 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
4028import comfy_extras
41- from nodes_upscale_model import UpscaleModelLoader , ImageUpscaleWithModel
29+ from comfy_extras . nodes_upscale_model import UpscaleModelLoader , ImageUpscaleWithModel
4230from comfy .model_management import soft_empty_cache , free_memory , get_torch_device , current_loaded_models , load_model_gpu
4331from nodes import LoraLoader , ConditioningAverage , common_ksampler , ImageScale , ImageScaleBy , VAEEncode , VAEDecode
4432import comfy .utils
@@ -142,6 +130,9 @@ def read_ratios():
142130 ratio_dict = data ['ratios' ]
143131 # user_styles.json
144132 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' )
145136 # check if file exists
146137 if os .path .isfile (user_styles_path ):
147138 # read json and update ratio_dict
@@ -161,6 +152,9 @@ def read_ratio_presets():
161152 ratio_preset_dict = data ['ratio_presets' ]
162153 # user_ratio_presets.json
163154 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' )
164158 # check if file exists
165159 if os .path .isfile (user_ratio_presets_path ):
166160 # read json and update ratio_dict
@@ -199,6 +193,9 @@ def read_styles():
199193 neg_style [style ] = data ['styles' ][style ]['negative' ]
200194 # user_styles.json
201195 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' )
202199 # check if file exists
203200 if os .path .isfile (user_styles_path ):
204201 # read json and update pos_style and neg_style
@@ -223,6 +220,9 @@ def read_styles():
223220def find_and_replace_wildcards (prompt , offset_seed , debug = False ):
224221 # wildcards use the __file_name__ syntax with optional |word_to_find
225222 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' )
226226 wildcard_regex = r'((\d+)\$\$)?__(!|\+|-|\*)?((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__'
227227 # r'(\[(\d+)\$\$)?__((?:[^|_]+_)*[^|_]+)((?:\|[^|]+)*)__\]?'
228228 match_strings = []
0 commit comments