mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
refactor backend detection
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
@@ -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):
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user