From 9f30abbad5a3bd89d24bbe74c9c438fb418d0c6d Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 2 Jan 2025 16:45:08 -0500 Subject: [PATCH] fix scheduler api Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 3 +++ extensions-builtin/sd-extension-system-info | 2 +- modules/api/api.py | 4 ++++ modules/api/models.py | 10 +++------- modules/shared.py | 8 ++++++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a24d8ff5..55ecccf30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - update installer messages - **Detailer**: - add explicit detailer steps setting +- **SysInfo**: + - update to collected data and benchmarks - **Fixes**: - explict clear caches on model load - lock adetailer commit: `#a89c01d` @@ -23,6 +25,7 @@ - vae tiling use default value if not set - sd35 img2img - samplers test for scale noise before using + - scheduler api ## Update for 2024-12-31 diff --git a/extensions-builtin/sd-extension-system-info b/extensions-builtin/sd-extension-system-info index dfa01ce99..aafc660ba 160000 --- a/extensions-builtin/sd-extension-system-info +++ b/extensions-builtin/sd-extension-system-info @@ -1 +1 @@ -Subproject commit dfa01ce99a17d76b45284ef28cef018ff52ac353 +Subproject commit aafc660ba3cf78724059917f7c3a05f3ac1ed46a diff --git a/modules/api/api.py b/modules/api/api.py index b958085ea..b38456d8f 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -99,6 +99,10 @@ def __init__(self, app: FastAPI, queue_lock: Lock): # gallery api gallery.register_api(app) + # compatibility api + self.text2imgapi = self.generate.post_text2img + self.img2imgapi = self.generate.post_img2img + def add_api_route(self, path: str, endpoint, **kwargs): if (shared.cmd_opts.auth or shared.cmd_opts.auth_file) and shared.cmd_opts.api_only: return self.app.add_api_route(path, endpoint, dependencies=[Depends(self.auth)], **kwargs) diff --git a/modules/api/models.py b/modules/api/models.py index 39bcbe383..ce423b639 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -1,5 +1,5 @@ import inspect -from typing import Any, Optional, Dict, List, Type, Callable +from typing import Any, Optional, Dict, List, Type, Callable, Union from pydantic import BaseModel, Field, create_model # pylint: disable=no-name-in-module from inflection import underscore from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img @@ -194,7 +194,7 @@ class ItemExtension(BaseModel): "StableDiffusionProcessingTxt2Img", StableDiffusionProcessingTxt2Img, [ - {"key": "sampler_index", "type": int, "default": 0}, + {"key": "sampler_index", "type": Union[int, str], "default": 0}, {"key": "sampler_name", "type": str, "default": "UniPC"}, {"key": "hr_sampler_name", "type": str, "default": "Same as primary"}, {"key": "script_name", "type": str, "default": "none"}, @@ -218,7 +218,7 @@ class ResTxt2Img(BaseModel): "StableDiffusionProcessingImg2Img", StableDiffusionProcessingImg2Img, [ - {"key": "sampler_index", "type": int, "default": 0}, + {"key": "sampler_index", "type": Union[int, str], "default": 0}, {"key": "sampler_name", "type": str, "default": "UniPC"}, {"key": "hr_sampler_name", "type": str, "default": "Same as primary"}, {"key": "script_name", "type": str, "default": "none"}, @@ -405,10 +405,6 @@ class ResNVML(BaseModel): # definition of http response state: str = Field(title="State") -# compatibility items -StableDiffusionTxt2ImgProcessingAPI = ResTxt2Img -StableDiffusionImg2ImgProcessingAPI = ResImg2Img - # helper function def create_model_from_signature(func: Callable, model_name: str, base_model: Type[BaseModel] = BaseModel, additional_fields: List = [], exclude_fields: List[str] = []): diff --git a/modules/shared.py b/modules/shared.py index 2ccb1e0a9..6150017d0 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -303,8 +303,12 @@ def validate(self, opt, value): # return False minimum = args.get("minimum", None) maximum = args.get("maximum", None) - if (minimum is not None and value < minimum) or (maximum is not None and value > maximum): - log.error(f'Setting validation: "{opt}"={value} default={self.default} minimum={minimum} maximum={maximum}') + try: + if (minimum is not None and value < minimum) or (maximum is not None and value > maximum): + log.error(f'Setting validation: "{opt}"={value} default={self.default} minimum={minimum} maximum={maximum}') + return False + except Exception as err: + log.error(f'Setting validation: "{opt}"={value} default={self.default} minimum={minimum} maximum={maximum} error={err}') return False return True