Skip to content

Commit

Permalink
update for sd_turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
olegchomp authored Jun 16, 2024
1 parent 73b4ec8 commit ff95b4e
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions TouchDiffusionExt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
formated_time = current_time.strftime("%H:%M:%S")
op('fifo1').appendRow([formated_time, 'Error', e])


class TouchDiffusionExt:
"""
DefaultExt description
Expand Down Expand Up @@ -63,15 +62,20 @@ def activate_stream(self):
)

self.stream.prepare(
prompt = parent().par.Prompt.val,
negative_prompt = parent().par.Negprompt.val,
guidance_scale=parent().par.Cfgscale.val,
delta=parent().par.Deltamult.val,
prompt = parent().par.Prompt.eval(),
negative_prompt = parent().par.Negprompt.eval(),
guidance_scale=parent().par.Cfgscale.eval(),
delta=parent().par.Deltamult.eval(),
t_index_list=self.update_denoising_strength()
)


menuindex = parent().par.Enginelist.menuIndex
menulabel = parent().par.Enginelist.menuLabels[menuindex]
parent().par.Activeengine = menulabel
self.fifolog('Status', 'Engine activated')
except Exception as e:
parent().par.Activeengine = 'None'
self.fifolog('Error', e)

def generate(self, scriptOp):
Expand Down Expand Up @@ -104,9 +108,9 @@ def preprocess_image(self, image):
image = torch.flip(image, [1])
image = torch.clamp(image, 0, 1)
image = image[:3, :, :]
_, h, w = image.shape
#_, h, w = image.shape
# Resize to integer multiple of 32
h, w = map(lambda x: x - x % 32, (h, w))
#h, w = map(lambda x: x - x % 32, (h, w))
#image = self.blend_tensors(self.prev_frame, image, 0.5)
image = image.unsqueeze(0)
return image
Expand Down Expand Up @@ -172,7 +176,8 @@ def update_selected_engine(self):


def update_prompt(self):
prompt = parent().par.Prompt.val
prompt = parent().par.Prompt.eval()
print(prompt)
self.stream.touchdiffusion_prompt(prompt)

def prompt_to_str(self):
Expand All @@ -199,8 +204,8 @@ def update_scheduler(self):
self.stream.touchdiffusion_scheduler(t_index_list)

def update_denoising_strength(self):
amount = parent().par.Denoise
mode = parent().par.Denoisemode
amount = parent().par.Denoise.eval()
mode = parent().par.Denoisemode.eval()
#self.stream.touchdiffusion_generate_t_index_list(amount, mode)
t_index_list = self.stream.touchdiffusion_generate_t_index_list(amount, mode)
return t_index_list
Expand All @@ -214,12 +219,12 @@ def generate_t_index_list(self):


def update_cfg_setting(self):
guidance_scale = parent().par.Cfgscale
delta = parent().par.Deltamult.val
guidance_scale = parent().par.Cfgscale.eval()
delta = parent().par.Deltamult.eval()
self.stream.touchdiffusion_update_cfg_setting(guidance_scale=guidance_scale, delta=delta)

def update_noise(self):
seed = parent().par.Seed.val
seed = parent().par.Seed.eval()
self.stream.touchdiffusion_update_noise(seed=seed)


Expand All @@ -233,13 +238,15 @@ def parexec_onValueChange(self, par, prev):
self.update_cfg_setting()
elif par.name == 'Seed':
self.update_noise()
if par.name == 'Enginelist':
self.update_selected_engine()

def parexec_onPulse(self, par):
if par.name == 'Loadengine':
self.activate_stream()
elif par.name == 'Refreshenginelist':
self.update_engines()
if par.name[0:3] == 'Url':
elif par.name[0:3] == 'Url':
self.about(par.name)

def fifolog(self, status, message):
Expand Down

0 comments on commit ff95b4e

Please sign in to comment.