Skip to content

Commit 5547872

Browse files
Merge pull request #5117 from aliencaocao/fix_api_sampler_name
Fix api ignoring sampler_name settings
2 parents 8c8ad93 + 06ada73 commit 5547872

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/api/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ def auth(self, credenticals: HTTPBasicCredentials = Depends(HTTPBasic())):
112112
def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):
113113
populate = txt2imgreq.copy(update={ # Override __init__ params
114114
"sd_model": shared.sd_model,
115-
"sampler_name": validate_sampler_name(txt2imgreq.sampler_index),
115+
"sampler_name": validate_sampler_name(txt2imgreq.sampler_name or txt2imgreq.sampler_index),
116116
"do_not_save_samples": True,
117117
"do_not_save_grid": True
118118
}
119119
)
120+
if populate.sampler_name:
121+
populate.sampler_index = None # prevent a warning later on
120122
p = StableDiffusionProcessingTxt2Img(**vars(populate))
121123
# Override object param
122124

@@ -142,12 +144,14 @@ def img2imgapi(self, img2imgreq: StableDiffusionImg2ImgProcessingAPI):
142144

143145
populate = img2imgreq.copy(update={ # Override __init__ params
144146
"sd_model": shared.sd_model,
145-
"sampler_name": validate_sampler_name(img2imgreq.sampler_index),
147+
"sampler_name": validate_sampler_name(img2imgreq.sampler_name or img2imgreq.sampler_index),
146148
"do_not_save_samples": True,
147149
"do_not_save_grid": True,
148150
"mask": mask
149151
}
150152
)
153+
if populate.sampler_name:
154+
populate.sampler_index = None # prevent a warning later on
151155
p = StableDiffusionProcessingImg2Img(**vars(populate))
152156

153157
imgs = []

0 commit comments

Comments
 (0)