Skip to content

Commit

Permalink
Do not replace existing values on empty extra parameters apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Aristarhys committed Nov 11, 2023
1 parent 6b55dd5 commit fc295bf
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit fc295bf

Please sign in to comment.