From 3cf93de24f90247af33ab9cf743a6eb45308d668 Mon Sep 17 00:00:00 2001 From: Billy Cao Date: Sun, 27 Nov 2022 21:12:37 +0800 Subject: [PATCH 1/2] Fix sampler_name for API requests are being ignored --- modules/api/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/api/api.py b/modules/api/api.py index efcedbba2..539805513 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -112,7 +112,7 @@ class Api: def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI): populate = txt2imgreq.copy(update={ # Override __init__ params "sd_model": shared.sd_model, - "sampler_name": validate_sampler_name(txt2imgreq.sampler_index), + "sampler_name": validate_sampler_name(txt2imgreq.sampler_name or txt2imgreq.sampler_index), "do_not_save_samples": True, "do_not_save_grid": True } @@ -142,7 +142,7 @@ class Api: populate = img2imgreq.copy(update={ # Override __init__ params "sd_model": shared.sd_model, - "sampler_name": validate_sampler_name(img2imgreq.sampler_index), + "sampler_name": validate_sampler_name(img2imgreq.sampler_name or img2imgreq.sampler_index), "do_not_save_samples": True, "do_not_save_grid": True, "mask": mask From 06ada734c7f85e5e6e2e6ae78fb873be0222bfd5 Mon Sep 17 00:00:00 2001 From: Billy Cao Date: Sun, 27 Nov 2022 21:19:47 +0800 Subject: [PATCH 2/2] Prevent warning on sampler_index if sampler_name is being used --- modules/api/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/api/api.py b/modules/api/api.py index 539805513..2f450fc4f 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -117,6 +117,8 @@ class Api: "do_not_save_grid": True } ) + if populate.sampler_name: + populate.sampler_index = None # prevent a warning later on p = StableDiffusionProcessingTxt2Img(**vars(populate)) # Override object param @@ -148,6 +150,8 @@ class Api: "mask": mask } ) + if populate.sampler_name: + populate.sampler_index = None # prevent a warning later on p = StableDiffusionProcessingImg2Img(**vars(populate)) imgs = []