From 0af9028b41ef4b66c3169a1e10c78550418abfc4 Mon Sep 17 00:00:00 2001 From: sudoskys Date: Mon, 22 Apr 2024 21:14:33 +0800 Subject: [PATCH 1/4] :bug: fix(ai/generate_image): Fix uncond_scale comparison in generate_image module --- src/novelai_python/sdk/ai/generate_image/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/novelai_python/sdk/ai/generate_image/__init__.py b/src/novelai_python/sdk/ai/generate_image/__init__.py index ac69510..1b32c6c 100755 --- a/src/novelai_python/sdk/ai/generate_image/__init__.py +++ b/src/novelai_python/sdk/ai/generate_image/__init__.py @@ -453,7 +453,7 @@ def calculate_cost(self, is_opus: bool = False): ) per_sample = max(math.ceil(per_sample * strength), 2) - if uncond_scale != 1.0: + if int(uncond_scale) != 1: per_sample = math.ceil(per_sample * 1.3) return per_sample * n_samples From 2f48c38c05e938f9c33bf23cb7dcb44bf4601961 Mon Sep 17 00:00:00 2001 From: sudoskys Date: Thu, 25 Apr 2024 10:34:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20chore:=20update=20e?= =?UTF-8?q?num.py=20with=20new=20models=20for=20image=20generation=20and?= =?UTF-8?q?=20inpainting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added new models for furry diffusion image generation and inpainting - Updated the list of inpainting models - Added new promotion mappings for furry diffusion models --- .../sdk/ai/generate_image/_enum.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/novelai_python/sdk/ai/generate_image/_enum.py b/src/novelai_python/sdk/ai/generate_image/_enum.py index 28da946..22dfe8b 100755 --- a/src/novelai_python/sdk/ai/generate_image/_enum.py +++ b/src/novelai_python/sdk/ai/generate_image/_enum.py @@ -93,6 +93,9 @@ class Model(Enum): NAI_DIFFUSION_3 = "nai-diffusion-3" NAI_DIFFUSION_3_INPAINTING = "nai-diffusion-3-inpainting" + NAI_DIFFUSION_FURRY_3 = "nai-diffusion-furry-3" + NAI_DIFFUSION_FURRY_3_INPAINTING = "nai-diffusion-furry-3-inpainting" + NAI_DIFFUSION = "nai-diffusion" NAI_DIFFUSION_2 = "nai-diffusion-2" NAI_DIFFUSION_INPAINTING = "nai-diffusion-inpainting" @@ -107,11 +110,13 @@ class Model(Enum): CUSTOM = "custom" -INPAINTING_MODEL_LIST = [Model.NAI_DIFFUSION_3_INPAINTING, - Model.NAI_DIFFUSION_INPAINTING, - Model.SAFE_DIFFUSION_INPAINTING, - Model.FURRY_DIFFUSION_INPAINTING - ] +INPAINTING_MODEL_LIST = [ + Model.NAI_DIFFUSION_3_INPAINTING, + Model.NAI_DIFFUSION_INPAINTING, + Model.SAFE_DIFFUSION_INPAINTING, + Model.FURRY_DIFFUSION_INPAINTING, + Model.NAI_DIFFUSION_FURRY_3_INPAINTING +] PROMOTION = { "Stable Diffusion 1D44365E": Model.SAFE_DIFFUSION, @@ -127,4 +132,7 @@ class Model(Enum): "Stable Diffusion XL B0BDF6C1": Model.NAI_DIFFUSION_3, "Stable Diffusion XL C1E1DE52": Model.NAI_DIFFUSION_3, "Stable Diffusion XL 8BA2AF87": Model.NAI_DIFFUSION_3, + "Stable Diffusion XL 4BE8C60C": Model.NAI_DIFFUSION_FURRY_3, + "Stable Diffusion XL C8704949": Model.NAI_DIFFUSION_FURRY_3, + "Stable Diffusion XL 9CC2F394": Model.NAI_DIFFUSION_FURRY_3, } From f107b1c32bf7e13ccea066c78db9fa527b29dbd1 Mon Sep 17 00:00:00 2001 From: sudoskys Date: Thu, 25 Apr 2024 11:11:22 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20RequestParams=20i?= =?UTF-8?q?mport=20to=20generate=5Fimage=20=5F=5Finit=5F=5F.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 fix: remove unused import in _enum.py 🔧 refactor: restructure ImageGenerateResp class in generate_image.py 🔧 refactor: update function parameters in server.py --- src/novelai_python/_response/ai/generate_image.py | 9 +++++---- src/novelai_python/sdk/ai/generate/_enum.py | 2 +- src/novelai_python/sdk/ai/generate_image/__init__.py | 4 ++-- src/novelai_python/server.py | 6 +++++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/novelai_python/_response/ai/generate_image.py b/src/novelai_python/_response/ai/generate_image.py index 1986cdc..32a9dfb 100755 --- a/src/novelai_python/_response/ai/generate_image.py +++ b/src/novelai_python/_response/ai/generate_image.py @@ -10,11 +10,12 @@ from ..schema import RespBase -class ImageGenerateResp(RespBase): - class RequestParams(BaseModel): - endpoint: str - raw_request: dict = None +class RequestParams(BaseModel): + endpoint: str + raw_request: dict = None + +class ImageGenerateResp(RespBase): meta: RequestParams files: List[Tuple[str, bytes]] = None diff --git a/src/novelai_python/sdk/ai/generate/_enum.py b/src/novelai_python/sdk/ai/generate/_enum.py index 6d35c80..625f2ce 100644 --- a/src/novelai_python/sdk/ai/generate/_enum.py +++ b/src/novelai_python/sdk/ai/generate/_enum.py @@ -1,6 +1,6 @@ # Description: Enum class for TextLLMModel from enum import Enum -from typing import List, Dict +from typing import List class TextLLMModel(Enum): diff --git a/src/novelai_python/sdk/ai/generate_image/__init__.py b/src/novelai_python/sdk/ai/generate_image/__init__.py index 1b32c6c..8edc503 100755 --- a/src/novelai_python/sdk/ai/generate_image/__init__.py +++ b/src/novelai_python/sdk/ai/generate_image/__init__.py @@ -28,7 +28,7 @@ from ._enum import Model, Sampler, NoiseSchedule, ControlNetModel, Action, UCPreset, INPAINTING_MODEL_LIST from ...schema import ApiBaseModel from ...._exceptions import APIError, AuthError, ConcurrentGenerationError, SessionHttpError -from ...._response.ai.generate_image import ImageGenerateResp +from ...._response.ai.generate_image import ImageGenerateResp, RequestParams from ....credential import CredentialBase from ....utils import try_jsonfy @@ -755,7 +755,7 @@ async def request(self, data = zip_file.read(filename) unzip_content.append((filename, data)) return ImageGenerateResp( - meta=ImageGenerateResp.RequestParams( + meta=RequestParams( endpoint=self.base_url, raw_request=request_data, ), diff --git a/src/novelai_python/server.py b/src/novelai_python/server.py index 4376a63..5d8524a 100755 --- a/src/novelai_python/server.py +++ b/src/novelai_python/server.py @@ -226,7 +226,11 @@ async def generate_voice( """ 生成图片 :param current_token: Authorization - :param req: GenerateImageInfer + :param text: str + :param voice: int + :param seed: Optional[str] + :param opus: bool + :param version: Union[Literal["v2", "v1"], str] :return: """ try: From 19213eb2138de29484b4f1748ddb893732dc395c Mon Sep 17 00:00:00 2001 From: sudoskys Date: Thu, 25 Apr 2024 11:11:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20RequestParams=20i?= =?UTF-8?q?mport=20to=20generate=5Fimage=20=5F=5Finit=5F=5F.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 fix: remove unused import in _enum.py 🔧 refactor: restructure ImageGenerateResp class in generate_image.py 🔧 refactor: update function parameters in server.py --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 92b0a44..7c10106 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "novelai-python" -version = "0.4.8" +version = "0.4.9" description = "NovelAI Python Binding With Pydantic" authors = [ { name = "sudoskys", email = "coldlando@hotmail.com" },