Changed alwayson_script_name and alwayson_script_args api params to 1 alwayson_scripts param dict
This commit is contained in:
parent
c6c2a59333
commit
2174f58dae
@ -195,22 +195,17 @@ class Api:
|
|||||||
script_args[0] = 0
|
script_args[0] = 0
|
||||||
|
|
||||||
# Now check for always on scripts
|
# Now check for always on scripts
|
||||||
if request.alwayson_script_name and (len(request.alwayson_script_name) > 0):
|
if request.alwayson_scripts and (len(request.alwayson_scripts) > 0):
|
||||||
# always on script with no arg should always run, but if you include their name in the api request, send an empty list for there args
|
for alwayson_script_name in request.alwayson_scripts.keys():
|
||||||
if not request.alwayson_script_args:
|
|
||||||
raise HTTPException(status_code=422, detail=f"Script {request.alwayson_script_name} has no arg list")
|
|
||||||
if len(request.alwayson_script_name) != len(request.alwayson_script_args):
|
|
||||||
raise HTTPException(status_code=422, detail=f"Number of script names and number of script arg lists doesn't match")
|
|
||||||
|
|
||||||
for alwayson_script_name, alwayson_script_args in zip(request.alwayson_script_name, request.alwayson_script_args):
|
|
||||||
alwayson_script = self.get_script(alwayson_script_name, script_runner)
|
alwayson_script = self.get_script(alwayson_script_name, script_runner)
|
||||||
if alwayson_script == None:
|
if alwayson_script == None:
|
||||||
raise HTTPException(status_code=422, detail=f"always on script {alwayson_script_name} not found")
|
raise HTTPException(status_code=422, detail=f"always on script {alwayson_script_name} not found")
|
||||||
# Selectable script in always on script param check
|
# Selectable script in always on script param check
|
||||||
if alwayson_script.alwayson == False:
|
if alwayson_script.alwayson == False:
|
||||||
raise HTTPException(status_code=422, detail=f"Cannot have a selectable script in the always on scripts params")
|
raise HTTPException(status_code=422, detail=f"Cannot have a selectable script in the always on scripts params")
|
||||||
if alwayson_script_args != []:
|
# always on script with no arg should always run so you don't really need to add them to the requests
|
||||||
script_args[alwayson_script.args_from:alwayson_script.args_to] = alwayson_script_args
|
if "args" in request.alwayson_scripts[alwayson_script_name]:
|
||||||
|
script_args[alwayson_script.args_from:alwayson_script.args_to] = request.alwayson_scripts[alwayson_script_name]["args"]
|
||||||
return script_args
|
return script_args
|
||||||
|
|
||||||
def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):
|
def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):
|
||||||
@ -226,15 +221,13 @@ class Api:
|
|||||||
"do_not_save_grid": True
|
"do_not_save_grid": True
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if populate.sampler_name:
|
if populate.sampler_name:
|
||||||
populate.sampler_index = None # prevent a warning later on
|
populate.sampler_index = None # prevent a warning later on
|
||||||
|
|
||||||
args = vars(populate)
|
args = vars(populate)
|
||||||
args.pop('script_name', None)
|
args.pop('script_name', None)
|
||||||
args.pop('script_args', None) # will refeed them to the pipeline directly after initializing them
|
args.pop('script_args', None) # will refeed them to the pipeline directly after initializing them
|
||||||
args.pop('alwayson_script_name', None)
|
args.pop('alwayson_scripts', None)
|
||||||
args.pop('alwayson_script_args', None)
|
|
||||||
|
|
||||||
script_args = self.init_script_args(txt2imgreq, selectable_scripts, selectable_script_idx, script_runner)
|
script_args = self.init_script_args(txt2imgreq, selectable_scripts, selectable_script_idx, script_runner)
|
||||||
|
|
||||||
@ -279,7 +272,6 @@ class Api:
|
|||||||
"mask": mask
|
"mask": mask
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if populate.sampler_name:
|
if populate.sampler_name:
|
||||||
populate.sampler_index = None # prevent a warning later on
|
populate.sampler_index = None # prevent a warning later on
|
||||||
|
|
||||||
@ -287,8 +279,7 @@ class Api:
|
|||||||
args.pop('include_init_images', None) # this is meant to be done by "exclude": True in model, but it's for a reason that I cannot determine.
|
args.pop('include_init_images', None) # this is meant to be done by "exclude": True in model, but it's for a reason that I cannot determine.
|
||||||
args.pop('script_name', None)
|
args.pop('script_name', None)
|
||||||
args.pop('script_args', None) # will refeed them to the pipeline directly after initializing them
|
args.pop('script_args', None) # will refeed them to the pipeline directly after initializing them
|
||||||
args.pop('alwayson_script_name', None)
|
args.pop('alwayson_scripts', None)
|
||||||
args.pop('alwayson_script_args', None)
|
|
||||||
|
|
||||||
script_args = self.init_script_args(img2imgreq, selectable_scripts, selectable_script_idx, script_runner)
|
script_args = self.init_script_args(img2imgreq, selectable_scripts, selectable_script_idx, script_runner)
|
||||||
|
|
||||||
|
@ -100,13 +100,13 @@ class PydanticModelGenerator:
|
|||||||
StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator(
|
StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator(
|
||||||
"StableDiffusionProcessingTxt2Img",
|
"StableDiffusionProcessingTxt2Img",
|
||||||
StableDiffusionProcessingTxt2Img,
|
StableDiffusionProcessingTxt2Img,
|
||||||
[{"key": "sampler_index", "type": str, "default": "Euler"}, {"key": "script_name", "type": str, "default": None}, {"key": "script_args", "type": list, "default": []}, {"key": "alwayson_script_name", "type": list, "default": []}, {"key": "alwayson_script_args", "type": list, "default": []}]
|
[{"key": "sampler_index", "type": str, "default": "Euler"}, {"key": "script_name", "type": str, "default": None}, {"key": "script_args", "type": list, "default": []}, {"key": "alwayson_scripts", "type": dict, "default": {}}]
|
||||||
).generate_model()
|
).generate_model()
|
||||||
|
|
||||||
StableDiffusionImg2ImgProcessingAPI = PydanticModelGenerator(
|
StableDiffusionImg2ImgProcessingAPI = PydanticModelGenerator(
|
||||||
"StableDiffusionProcessingImg2Img",
|
"StableDiffusionProcessingImg2Img",
|
||||||
StableDiffusionProcessingImg2Img,
|
StableDiffusionProcessingImg2Img,
|
||||||
[{"key": "sampler_index", "type": str, "default": "Euler"}, {"key": "init_images", "type": list, "default": None}, {"key": "denoising_strength", "type": float, "default": 0.75}, {"key": "mask", "type": str, "default": None}, {"key": "include_init_images", "type": bool, "default": False, "exclude" : True}, {"key": "script_name", "type": str, "default": None}, {"key": "script_args", "type": list, "default": []}, {"key": "alwayson_script_name", "type": list, "default": []}, {"key": "alwayson_script_args", "type": list, "default": []}]
|
[{"key": "sampler_index", "type": str, "default": "Euler"}, {"key": "init_images", "type": list, "default": None}, {"key": "denoising_strength", "type": float, "default": 0.75}, {"key": "mask", "type": str, "default": None}, {"key": "include_init_images", "type": bool, "default": False, "exclude" : True}, {"key": "script_name", "type": str, "default": None}, {"key": "script_args", "type": list, "default": []}, {"key": "alwayson_scripts", "type": dict, "default": {}}]
|
||||||
).generate_model()
|
).generate_model()
|
||||||
|
|
||||||
class TextToImageResponse(BaseModel):
|
class TextToImageResponse(BaseModel):
|
||||||
|
Loading…
Reference in New Issue
Block a user