Skip to content

Commit

Permalink
Add option to randomize seed in live mode after copying the image #214
Browse files Browse the repository at this point in the history
  • Loading branch information
Acly committed Dec 21, 2023
1 parent f420253 commit 948bfc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ai_diffusion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class Model(QObject, metaclass=PropertyMeta):
negative_prompt = Property("")
control: ControlLayerList
strength = Property(1.0)
upscale: UpscaleWorkspace
live: LiveWorkspace
upscale: "UpscaleWorkspace"
live: "LiveWorkspace"
progress = Property(0.0)
jobs: JobQueue
error = Property("")
Expand Down Expand Up @@ -446,6 +446,8 @@ def copy_result_to_layer(self):
assert self.result is not None and self._result_bounds is not None
doc = self._model.document
doc.insert_layer(f"[Live] {self._model.prompt}", self.result, self._result_bounds)
if settings.new_seed_after_apply:
self.generate_seed()

@property
def result(self):
Expand Down
7 changes: 7 additions & 0 deletions ai_diffusion/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ class Settings(QObject):
"Random Seed", "0", "Random number to produce different results with each generation"
)

new_seed_after_apply: bool
_new_seed_after_apply = Setting(
"Live: New Seed after Apply",
False,
"Pick a new seed after copying the result to the canvas in Live mode",
)

prompt_line_count: int
_prompt_line_count = Setting(
"Prompt Line Count", 2, "Size of the text editor for image descriptions"
Expand Down
3 changes: 2 additions & 1 deletion ai_diffusion/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,8 @@ def __init__(self):
"show_negative_prompt", SwitchSetting(S._show_negative_prompt, ("Show", "Hide"), self)
)
self.add("show_control_end", SwitchSetting(S._show_control_end, ("Show", "Hide"), self))
self.add("auto_preview", SwitchSetting(S._auto_preview, ("On", "Off"), self))
self.add("auto_preview", SwitchSetting(S._auto_preview, parent=self))
self.add("new_seed_after_apply", SwitchSetting(S._new_seed_after_apply, parent=self))

self._layout.addStretch()

Expand Down

0 comments on commit 948bfc7

Please sign in to comment.