Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix(generate_image): update ucPreset handling and imports #73

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading