Skip to content

Commit

Permalink
Merge pull request #59 from LlmKira/dev
Browse files Browse the repository at this point in the history
add NAI_DIFFUSION_FURRY_3
  • Loading branch information
sudoskys authored Apr 25, 2024
2 parents 4764d58 + 19213eb commit b80267a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
Expand Down
9 changes: 5 additions & 4 deletions src/novelai_python/_response/ai/generate_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/novelai_python/sdk/ai/generate/_enum.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 3 additions & 3 deletions src/novelai_python/sdk/ai/generate_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
),
Expand Down
18 changes: 13 additions & 5 deletions src/novelai_python/sdk/ai/generate_image/_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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,
}
6 changes: 5 additions & 1 deletion src/novelai_python/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b80267a

Please sign in to comment.