From f1b6971f7edb922ec5f180c6fc9da1a12b57159f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Sad=C4=B1k=20=C3=96zbek?= Date: Mon, 8 Jan 2024 22:45:16 +0300 Subject: [PATCH 1/2] Update FaceID api params --- modules/api/api.py | 13 +++++++++++-- modules/api/models.py | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/api/api.py b/modules/api/api.py index 965910b15..1a0eeab56 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -263,7 +263,16 @@ class Api: def prepare_img_gen_request(self, request, img_gen_type: str): if hasattr(request, "face_id") and request.face_id and not request.script_name and (not request.alwayson_scripts or "FaceID" not in request.alwayson_scripts.keys()): request.script_name = "FaceID" - request.script_args = [request.face_id.scale, request.face_id.image] + request.script_args = [ + request.face_id.model, + request.face_id.scale, + request.face_id.image, + request.face_id.override_sampler, + request.face_id.rank, + request.face_id.tokens, + request.face_id.structure, + request.face_id.cache_model + ] del request.face_id if hasattr(request, "ip_adapter") and request.ip_adapter and request.script_name != "IP Adapter" and (not request.alwayson_scripts or "IP Adapter" not in request.alwayson_scripts.keys()): @@ -283,7 +292,7 @@ class Api: for script_name in request.alwayson_scripts.keys(): script_obj = request.alwayson_scripts[script_name] - if "args" in script_obj and script_obj["args"]: + if script_obj and "args" in script_obj and script_obj["args"]: self.sanitize_args(script_obj["args"]) if hasattr(request, "script_args") and request.script_args: diff --git a/modules/api/models.py b/modules/api/models.py index d9063e61c..d5254ce0a 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -99,8 +99,14 @@ class IPAdapterItem(BaseModel): class FaceIDItem(BaseModel): + model: str = Field(title="Model", default="FaceID Base",description="The FaceID model to use.") image: str = Field(title="Image", default="", description="Source face image, must be a base64 string containing the image's data.") - scale: float = Field(title="Scale", default=0.5, gt=0, le=1, description="Scale of the source face, must be between 0 and 1.") + scale: float = Field(title="Scale", default=1, gt=0, le=1, description="Scale of the source face, must be between 0 and 1.") + structure: float = Field(title="Structure", default=1, gt=0, le=1, description="Structure to use, must be between 0 and 1.") + rank: float = Field(title="Rank", default=128, ge=4, le=256, description="Rank to use, must be between 0 and 1.") + override_sampler: bool = Field(title="Override Sampler", default=True, description="Should the sampler be overriden?") + tokens: int = Field("Tokens", default=4, ge=1, le=16, description="Amount of tokens to use") + cache_model: bool = Field(title="Cache", default=True, description="Should the model be cached?") StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator( From 9d2446f359dddc56b64056e8fb420282aec0119b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Sad=C4=B1k=20=C3=96zbek?= Date: Mon, 8 Jan 2024 22:47:19 +0300 Subject: [PATCH 2/2] Fix model descriptions for FaceID --- modules/api/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/api/models.py b/modules/api/models.py index d5254ce0a..86b2997af 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -103,9 +103,9 @@ class FaceIDItem(BaseModel): image: str = Field(title="Image", default="", description="Source face image, must be a base64 string containing the image's data.") scale: float = Field(title="Scale", default=1, gt=0, le=1, description="Scale of the source face, must be between 0 and 1.") structure: float = Field(title="Structure", default=1, gt=0, le=1, description="Structure to use, must be between 0 and 1.") - rank: float = Field(title="Rank", default=128, ge=4, le=256, description="Rank to use, must be between 0 and 1.") + rank: float = Field(title="Rank", default=128, ge=4, le=256, description="Rank to use, must be between 4 and 256.") override_sampler: bool = Field(title="Override Sampler", default=True, description="Should the sampler be overriden?") - tokens: int = Field("Tokens", default=4, ge=1, le=16, description="Amount of tokens to use") + tokens: int = Field("Tokens", default=4, ge=1, le=16, description="Amount of tokens to use, must be between 1 and 16.") cache_model: bool = Field(title="Cache", default=True, description="Should the model be cached?")