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

Prevent replacing existing values on empty extra parameters apply #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions scripts/two_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def do_visualize(self, raw_divisions: str, raw_positions: str, raw_weights: str)

return [f.create_tensor(1, 128, 128).squeeze(dim=0).cpu().numpy() for f in self.filters]

def do_apply(self, extra_generation_params: str):
def do_apply(self, extra_generation_params: str, divisions: str, positions: str, weights: str, end_at_step: int) -> Tuple[str, str, str, int]:
#
# parse "Latent Couple" extra_generation_params
#
Expand All @@ -245,7 +245,12 @@ def do_apply(self, extra_generation_params: str):
continue
raw_params[pair[0]] = pair[1]

return raw_params.get('divisions', '1:1,1:2,1:2'), raw_params.get('positions', '0:0,0:0,0:1'), raw_params.get('weights', '0.2,0.8,0.8'), int(raw_params.get('step', '20'))
step = raw_params.get('step')
if step is None:
step = end_at_step
else:
step = int(step)
return raw_params.get('divisions', divisions), raw_params.get('positions', positions), raw_params.get('weights', weights), step

def ui(self, is_img2img):
process_script_params = []
Expand Down Expand Up @@ -475,7 +480,7 @@ def paste_prompt(*input_prompts):
extra_generation_params = gr.Textbox(label="Extra generation params")
apply_button = gr.Button(value="Apply")

apply_button.click(fn=self.do_apply, inputs=[extra_generation_params], outputs=[divisions, positions, weights, end_at_step])
apply_button.click(fn=self.do_apply, inputs=[extra_generation_params, divisions, positions, weights, end_at_step], outputs=[divisions, positions, weights, end_at_step])

def select_twosoht_tab(tab_id):
self.selected_twoshot_tab = tab_id
Expand Down