refactor backend detection

This commit is contained in:
Vladimir Mandic
2024-06-06 20:41:10 -04:00
parent c8d6f03209
commit 5574833f0d
55 changed files with 171 additions and 170 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ orig_pipe = None # original sd_model pipeline
def set_adapter(adapter_name: str = 'None'):
if not shared.sd_loaded:
return
if shared.backend != shared.Backend.DIFFUSERS:
if not shared.native:
shared.log.warning('AnimateDiff: not in diffusers mode')
return
global motion_adapter, loaded_adapter, orig_pipe # pylint: disable=global-statement
@@ -135,7 +135,7 @@ class Script(scripts.Script):
return 'AnimateDiff'
def show(self, _is_img2img):
return scripts.AlwaysVisible if shared.backend == shared.Backend.DIFFUSERS else False
return scripts.AlwaysVisible if shared.native else False
def ui(self, _is_img2img):
+1 -1
View File
@@ -10,7 +10,7 @@ class Script(scripts.Script):
return title
def show(self, is_img2img):
return is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return is_img2img if shared.native else False
def ui(self, _is_img2img):
with gr.Row():
+1 -1
View File
@@ -1225,7 +1225,7 @@ class Script(scripts.Script):
return 'DemoFusion'
def show(self, is_img2img):
return not is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return not is_img2img if shared.native else False
# return signature is array of gradio components
def ui(self, _is_img2img):
+1 -1
View File
@@ -1875,7 +1875,7 @@ class Script(scripts.Script):
return 'Differential diffusion'
def show(self, is_img2img):
return is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return is_img2img if shared.native else False
def ui(self, _is_img2img):
with gr.Row():
+1 -1
View File
@@ -67,7 +67,7 @@ class Script(scripts.Script):
return title
def show(self, is_img2img):
if shared.backend == shared.Backend.DIFFUSERS:
if shared.native:
return img2img if is_img2img else txt2img
return False
+1 -1
View File
@@ -16,7 +16,7 @@ class Script(scripts.Script):
return 'Image-to-Video'
def show(self, is_img2img):
return is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return is_img2img if shared.native else False
# return False
# return signature is array of gradio components
+2 -2
View File
@@ -8,7 +8,7 @@ class Script(scripts.Script):
return 'Init Latents'
def show(self, is_img2img):
return scripts.AlwaysVisible if shared.backend == shared.Backend.DIFFUSERS else False
return scripts.AlwaysVisible if shared.native else False
@staticmethod
def get_latents(p):
@@ -31,7 +31,7 @@ class Script(scripts.Script):
def process_batch(self, p: processing.StableDiffusionProcessing, *args, **kwargs): # pylint: disable=arguments-differ
from modules.processing_helpers import create_random_tensors
if shared.backend != shared.Backend.DIFFUSERS:
if not shared.native:
return
args = list(args)
if p.subseed_strength != 0 and getattr(shared.sd_model, '_execution_device', None) is not None:
+2 -2
View File
@@ -14,7 +14,7 @@ class Script(scripts.Script):
return 'IP Adapters'
def show(self, is_img2img):
return scripts.AlwaysVisible if shared.backend == shared.Backend.DIFFUSERS else False
return scripts.AlwaysVisible if shared.native else False
def load_images(self, files):
init_images = []
@@ -83,7 +83,7 @@ class Script(scripts.Script):
return [num_adapters] + adapters + scales + files + starts + ends + masks + [layers_active] + [layers]
def process(self, p: processing.StableDiffusionProcessing, *args): # pylint: disable=arguments-differ
if shared.backend != shared.Backend.DIFFUSERS:
if not shared.native:
return
args = list(args) if args is not None else []
if len(args) == 0:
+1 -1
View File
@@ -8,7 +8,7 @@ class Script(scripts.Script):
return 'Kohya HiRes Fix'
def show(self, is_img2img):
return not is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return not is_img2img if shared.native else False
# return signature is array of gradio components
def ui(self, _is_img2img):
+1 -1
View File
@@ -8,7 +8,7 @@ class Script(scripts.Script):
return 'LayerDiffuse'
def show(self, is_img2img):
return True if shared.backend == shared.Backend.DIFFUSERS else False
return True if shared.native else False
def apply(self):
from modules import layerdiffuse
+1 -1
View File
@@ -8,7 +8,7 @@ class Script(scripts.Script):
return 'LEdits++'
def show(self, is_img2img):
return is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return is_img2img if shared.native else False
# return signature is array of gradio components
def ui(self, _is_img2img):
+1 -1
View File
@@ -29,7 +29,7 @@ class Script(scripts.Script):
return 'Mixture tiling'
def show(self, is_img2img):
return not is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return not is_img2img if shared.native else False
def ui(self, _is_img2img):
with gr.Row():
+1 -1
View File
@@ -50,7 +50,7 @@ class Script(scripts.Script):
def show(self, is_img2img):
if shared.cmd_opts.experimental:
return True if shared.backend == shared.Backend.DIFFUSERS else False
return True if shared.native else False
else:
return False
+1 -1
View File
@@ -24,7 +24,7 @@ class Script(scripts.Script):
return 'Regional prompting'
def show(self, is_img2img):
return not is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return not is_img2img if shared.native else False
def change(self, mode):
return [gr.update(visible='Col' in mode or 'Row' in mode), gr.update(visible='Prompt' in mode)]
+1 -1
View File
@@ -19,7 +19,7 @@ class Script(scripts.Script):
return 'Stable Video Diffusion'
def show(self, is_img2img):
return is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return is_img2img if shared.native else False
# return signature is array of gradio components
def ui(self, _is_img2img):
+1 -1
View File
@@ -8,7 +8,7 @@ class Script(scripts.Script):
return 'T-Gate'
def show(self, is_img2img):
return not is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return not is_img2img if shared.native else False
# return signature is array of gradio components
def ui(self, _is_img2img):
+1 -1
View File
@@ -26,7 +26,7 @@ class Script(scripts.Script):
return 'Text-to-Video'
def show(self, is_img2img):
return not is_img2img if shared.backend == shared.Backend.DIFFUSERS else False
return not is_img2img if shared.native else False
# return signature is array of gradio components
def ui(self, _is_img2img):
+1 -1
View File
@@ -16,7 +16,7 @@ class Script(scripts.Script):
def show(self, is_img2img):
return False
# return True if shared.backend == shared.Backend.DIFFUSERS else False
# return True if shared.native else False
def ui(self, _is_img2img):
with gr.Row():