Skip to content

Commit

Permalink
Bugfix for offline mode with local models in images modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Woolverine94 committed Jun 25, 2024
1 parent f0be01d commit 46f9835
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion ressources/magicmix.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def image_magicmix(
torch_dtype=model_arch,
use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex
)
Expand All @@ -98,7 +99,7 @@ def image_magicmix(
safety_checker=nsfw_filter_final,
feature_extractor=feat_ex,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)

pipe_magicmix = schedulerer(pipe_magicmix, sampler_magicmix)
Expand Down
1 change: 1 addition & 0 deletions ressources/paintbyex.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def image_paintbyex(
torch_dtype=model_arch,
# use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex,
)
Expand Down
6 changes: 4 additions & 2 deletions ressources/txt2img_kd.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def image_txt2img_kd(
modelid_txt2img_kd,
torch_dtype=model_arch,
use_safetensors=True,
local_files_only=True if offline_test() else None,
)
else :
pipe_txt2img_kd = AutoPipelineForText2Image.from_pretrained(
Expand All @@ -99,14 +100,15 @@ def image_txt2img_kd(
variant="fp16",
use_safetensors=True,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)
else :
if modelid_txt2img_kd[0:9] == "./models/" :
pipe_txt2img_kd = AutoPipelineForText2Image.from_single_file(
modelid_txt2img_kd,
torch_dtype=model_arch,
use_safetensors=True,
local_files_only=True if offline_test() else None,
)
else :
pipe_txt2img_kd = AutoPipelineForText2Image.from_pretrained(
Expand All @@ -115,7 +117,7 @@ def image_txt2img_kd(
torch_dtype=model_arch,
use_safetensors=True,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)

pipe_txt2img_kd = schedulerer(pipe_txt2img_kd, sampler_txt2img_kd)
Expand Down
3 changes: 2 additions & 1 deletion ressources/txt2img_mjm.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def image_txt2img_mjm(
torch_dtype=model_arch,
# use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex,
)
Expand All @@ -110,7 +111,7 @@ def image_txt2img_mjm(
safety_checker=nsfw_filter_final,
feature_extractor=feat_ex,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)

pipe_txt2img_mjm = schedulerer(pipe_txt2img_mjm, sampler_txt2img_mjm)
Expand Down
14 changes: 9 additions & 5 deletions ressources/txt2img_paa.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def image_txt2img_paa(
torch_dtype=model_arch,
use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex,
)
Expand All @@ -117,7 +118,7 @@ def image_txt2img_paa(
safety_checker=nsfw_filter_final,
feature_extractor=feat_ex,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)
pipe_txt2img_paa.scheduler = LCMScheduler.from_config(pipe_txt2img_paa.scheduler.config)
pipe_txt2img_paa.scheduler.config.prediction_type = "v_prediction"
Expand All @@ -133,7 +134,7 @@ def image_txt2img_paa(
torch_dtype=model_arch,
use_safetensors=True,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)

transformer_txt2img_paa = PeftModel.from_pretrained(
Expand All @@ -148,6 +149,7 @@ def image_txt2img_paa(
torch_dtype=model_arch,
use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex,
)
Expand All @@ -161,7 +163,7 @@ def image_txt2img_paa(
safety_checker=nsfw_filter_final,
feature_extractor=feat_ex,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)
pipe_txt2img_paa.scheduler = LCMScheduler.from_config(pipe_txt2img_paa.scheduler.config)
pipe_txt2img_paa.scheduler.config.timestep_spacing = "trailing"
Expand All @@ -173,6 +175,7 @@ def image_txt2img_paa(
torch_dtype=model_arch,
use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex,
)
Expand All @@ -185,7 +188,7 @@ def image_txt2img_paa(
safety_checker=nsfw_filter_final,
feature_extractor=feat_ex,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)
pipe_txt2img_paa = schedulerer(pipe_txt2img_paa, sampler_txt2img_paa)

Expand All @@ -196,6 +199,7 @@ def image_txt2img_paa(
torch_dtype=model_arch,
use_safetensors=True,
load_safety_checker=False if (nsfw_filter_final == None) else True,
local_files_only=True if offline_test() else None,
# safety_checker=nsfw_filter_final,
# feature_extractor=feat_ex,
)
Expand All @@ -208,7 +212,7 @@ def image_txt2img_paa(
safety_checker=nsfw_filter_final,
feature_extractor=feat_ex,
resume_download=True,
local_files_only=True if offline_test() else None
local_files_only=True if offline_test() else None,
)
pipe_txt2img_paa = schedulerer(pipe_txt2img_paa, sampler_txt2img_paa)

Expand Down

0 comments on commit 46f9835

Please sign in to comment.