Skip to content

Commit

Permalink
✨ feat(generate_image): enhance negative prompt handling and quality
Browse files Browse the repository at this point in the history
- Ensure `negative_prompt` is a string
- Add default negative prompt based on `ucPreset`
- Append quality prompts when `qualityToggle` is enabled
  • Loading branch information
sudoskys committed Sep 23, 2024
1 parent 8f2b66a commit d8959e9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/novelai_python/sdk/ai/generate_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,18 @@ def model_post_init(self, *args) -> None:
:param args: Any
:return: None
"""
# Must be a string
if self.parameters.negative_prompt is None:
self.parameters.negative_prompt = ""

# Add negative prompt based on ucPreset
if self.parameters.ucPreset is not None:
default_negative_prompt = get_default_uc_preset(self.model, self.parameters.ucPreset)
self.parameters.negative_prompt = ", ".join(
filter(None, [default_negative_prompt, self.parameters.negative_prompt])
)

# Add quality prompt
if self.parameters.qualityToggle:
self.input += ", best quality, amazing quality, very aesthetic, absurdres"

Expand Down

0 comments on commit d8959e9

Please sign in to comment.