Skip to content

Commit

Permalink
Merge pull request #73 from LlmKira/dev
Browse files Browse the repository at this point in the history
🐛 fix(generate_image): update ucPreset handling and imports
  • Loading branch information
sudoskys authored Sep 23, 2024
2 parents 3cca167 + a64534a commit 5d0135d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions playground/generate_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from novelai_python import APIError, LoginCredential
from novelai_python import GenerateImageInfer, ImageGenerateResp, JwtCredential
from novelai_python.sdk.ai._enum import Sampler
from novelai_python.sdk.ai.generate_image import Action, Model
from novelai_python.sdk.ai._enum import UCPreset
from novelai_python.sdk.ai.generate_image import Action, Model, Sampler
from novelai_python.utils.useful import enum_to_list


Expand All @@ -35,9 +35,10 @@ async def generate(prompt="1girl, year 2023, dynamic angle, best quality, amazin
model=Model.NAI_DIFFUSION_3,
action=Action.GENERATE,
sampler=Sampler.K_DPMPP_2M,
ucPreset=UCPreset.TYPE0, # Recommended, using preset negative_prompt depends on selected model
qualityToggle=True,
decrisp_mode=False,
variety_boost=True
variety_boost=True, # Checkbox in website
)
print(f"charge: {agent.calculate_cost(is_opus=True)} if you are vip3")
print(f"charge: {agent.calculate_cost(is_opus=False)} if you are not vip3")
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 @@ -138,8 +138,8 @@ def reference_strength_multiple_validator(cls, v):
# TODO: find out the usage
steps: Optional[int] = Field(23, ge=1, le=50)
"""Steps"""
ucPreset: Optional[UCPreset] = 0
"""The Negative Prompt Preset"""
ucPreset: Optional[Union[UCPreset, int]] = Field(None, ge=0)
"""The Negative Prompt Preset, Bigger or equal to 0"""
uncond_scale: Optional[float] = Field(1.0, ge=0, le=1.5, multiple_of=0.05)
"""Undesired Content Strength"""
width: Optional[int] = Field(832, ge=64, le=49152)
Expand Down Expand Up @@ -420,7 +420,7 @@ def build(cls,
model: Union[Model, str] = "nai-diffusion-3",
action: Union[Action, str] = 'generate',
negative_prompt: str = "",
ucPreset: Union[UCPreset, int] = UCPreset.TYPE0,
ucPreset: Optional[Union[UCPreset, int]] = UCPreset.TYPE0,
steps: int = 28,
seed: int = None,
scale: float = 5.0,
Expand Down

0 comments on commit 5d0135d

Please sign in to comment.