mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
reorganize scripts/extensions
Signed-off-by: vladmandic <mandic00@live.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from modules.logger import log
|
||||
debug = log.trace if os.environ.get('SD_FACE_DEBUG', None) is not None else lambda *args, **kwargs: None
|
||||
|
||||
|
||||
class Script(scripts_manager.Script):
|
||||
class FaceScript(scripts_manager.Script):
|
||||
original_pipeline = None
|
||||
original_prompt_attention = None
|
||||
|
||||
|
||||
@@ -16,10 +16,14 @@ errors.install()
|
||||
logging.getLogger("DeepSpeed").disabled = True
|
||||
timer.startup.record("loader")
|
||||
log.debug('Initializing: libraries')
|
||||
debug = os.environ.get('SD_LOAD_DEBUG')
|
||||
|
||||
|
||||
def report(msg: str, e: Exception):
|
||||
log.error(f'Loader: {msg} {e}')
|
||||
log.error('Please restart the app to fix this issue')
|
||||
if debug:
|
||||
errors.display(e, msg)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
@@ -46,9 +46,13 @@ class Script:
|
||||
paste_field_names = None
|
||||
section = None
|
||||
standalone = False
|
||||
external = False
|
||||
on_before_component_elem_id = [] # list of callbacks to be called before a component with an elem_id is created
|
||||
on_after_component_elem_id = [] # list of callbacks to be called after a component with an elem_id is created
|
||||
|
||||
def __str__(self):
|
||||
return f'Script: name="{self.name}" filename="{self.filename}" external={self.external} parent="{self.parent}" args_from={self.args_from} args_to={self.args_to} alwayson={self.alwayson} is_txt2img={self.is_txt2img} is_img2img={self.is_img2img}'
|
||||
|
||||
def title(self):
|
||||
"""this function should return the title of the script. This is what will be displayed in the dropdown menu."""
|
||||
raise NotImplementedError
|
||||
@@ -226,11 +230,11 @@ def list_scripts(scriptdirname, extension):
|
||||
if os.path.splitext(script.path)[1].lower() == extension and os.path.isfile(script.path):
|
||||
if script.basedir == paths.script_path:
|
||||
priority = '0'
|
||||
elif script.basedir.startswith(os.path.join(paths.script_path, 'scripts')):
|
||||
elif script.basedir.startswith(os.path.join(paths.script_path, 'scripts')) or script.basedir.startswith('scripts'):
|
||||
priority = '1'
|
||||
elif script.basedir.startswith(os.path.join(paths.script_path, 'extensions-builtin')):
|
||||
elif script.basedir.startswith(os.path.join(paths.script_path, 'extensions-builtin')) or script.basedir.startswith('extensions-builtin'):
|
||||
priority = '2'
|
||||
elif script.basedir.startswith(os.path.join(paths.script_path, 'extensions')):
|
||||
elif script.basedir.startswith(os.path.join(paths.script_path, 'extensions')) or script.basedir.startswith('extensions'):
|
||||
priority = '3'
|
||||
else:
|
||||
priority = '9'
|
||||
@@ -351,6 +355,8 @@ class ScriptRunner:
|
||||
script.filename = path
|
||||
script.is_txt2img = not is_img2img
|
||||
script.is_img2img = is_img2img
|
||||
if path.startswith(paths.extensions_dir) and not path.startswith(paths.extensions_builtin_dir):
|
||||
script.external = True
|
||||
if is_control: # this is messy but show is a legacy function that is not aware of control tab
|
||||
v1 = script.show(script.is_txt2img)
|
||||
v2 = script.show(script.is_img2img)
|
||||
@@ -458,6 +464,7 @@ class ScriptRunner:
|
||||
dropdown = gr.Dropdown(label="Script", elem_id=f'{parent}_script_list', choices=["None"] + self.titles, value="None", type="index")
|
||||
inputs.insert(0, dropdown)
|
||||
|
||||
# internal
|
||||
with gr.Row():
|
||||
for script in self.alwayson_scripts:
|
||||
if not script.standalone:
|
||||
@@ -471,10 +478,11 @@ class ScriptRunner:
|
||||
script.group = group
|
||||
time_setup[script.title()] = time_setup.get(script.title(), 0) + (time.time()-t0)
|
||||
|
||||
# extensions-builtin
|
||||
with gr.Row():
|
||||
with gr.Accordion(label="Extensions", elem_id=f'{parent}_script_alwayson') if accordion else gr.Group():
|
||||
with gr.Group(label="Extras", elem_id=f'{parent}_extras_alwayson'):
|
||||
for script in self.alwayson_scripts:
|
||||
if script.standalone:
|
||||
if script.standalone or script.external:
|
||||
continue
|
||||
if (self.name == 'control') and (paths.extensions_dir in script.filename) and (script.title() not in control_extensions):
|
||||
log.debug(f'Script: fn="{script.filename}" type={self.name} skip')
|
||||
@@ -485,6 +493,22 @@ class ScriptRunner:
|
||||
script.group = group
|
||||
time_setup[script.title()] = time_setup.get(script.title(), 0) + (time.time()-t0)
|
||||
|
||||
# extensions
|
||||
with gr.Row():
|
||||
with gr.Accordion(label="Extensions", elem_id=f'{parent}_script_alwayson') if accordion else gr.Group():
|
||||
for script in self.alwayson_scripts:
|
||||
if script.standalone or not script.external:
|
||||
continue
|
||||
if (self.name == 'control') and (paths.extensions_dir in script.filename) and (script.title() not in control_extensions):
|
||||
log.debug(f'Script: fn="{script.filename}" type={self.name} skip')
|
||||
continue
|
||||
t0 = time.time()
|
||||
with gr.Group(elem_id=f'{parent}_script_{script.title().lower().replace(" ", "_")}', elem_classes=['group-extension']) as group:
|
||||
create_script_ui(script, inputs, inputs_alwayson)
|
||||
script.group = group
|
||||
time_setup[script.title()] = time_setup.get(script.title(), 0) + (time.time()-t0)
|
||||
|
||||
|
||||
for script in self.selectable_scripts:
|
||||
if (self.name == 'control') and (paths.extensions_dir in script.filename) and (script.title() not in control_extensions):
|
||||
log.debug(f'Script: fn="{script.filename}" type={self.name} skip')
|
||||
|
||||
+11
-10
@@ -393,28 +393,29 @@ def create_html(search_text, sort_column):
|
||||
tags_text = ", ".join([f"<span class='extension-tag'>{x}</span>" for x in tags])
|
||||
if ext.get('status', None) is None or type(ext['status']) == str: # old format
|
||||
ext['status'] = 0
|
||||
style = "style='cursor: help;width: 1rem;margin: 0.2em;'"
|
||||
if ext['url'] is None or ext['url'] == '':
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Local'>{ui_symbols.svg_bullet.style('#00C0FD')}</div>"
|
||||
status = f"<div title='Local'>{ui_symbols.svg_bullet.style('#00C0FD')}</div>"
|
||||
elif ext['status'] > 0:
|
||||
if ext['status'] == 1:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Verified'>{ui_symbols.svg_bullet.style('#00FD9C')}</div>"
|
||||
status = f"<div {style} title='Verified'>{ui_symbols.svg_bullet.style('#00FD9C')}</div>"
|
||||
elif ext['status'] == 2:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Supported only with backend: Original'>{ui_symbols.svg_bullet.style('#FFC300')}</div>"
|
||||
status = f"<div {style} title='Supported only with backend: Original'>{ui_symbols.svg_bullet.style('#FFC300')}</div>"
|
||||
elif ext['status'] == 3:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Supported only with backend: Diffusers'>{ui_symbols.svg_bullet.style('#FFC300')}</div>"
|
||||
status = f"<div {style} title='Supported only with backend: Diffusers'>{ui_symbols.svg_bullet.style('#FFC300')}</div>"
|
||||
elif ext['status'] == 4:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title=\"{html.escape(ext.get('note', 'custom value'))}\">{ui_symbols.svg_bullet.style('#4E22FF')}</div>"
|
||||
status = f"<div {style} title=\"{html.escape(ext.get('note', 'custom value'))}\">{ui_symbols.svg_bullet.style('#4E22FF')}</div>"
|
||||
elif ext['status'] == 5:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Not supported'>{ui_symbols.svg_bullet.style('#CE0000')}</div>"
|
||||
status = f"<div {style} title='Not supported'>{ui_symbols.svg_bullet.style('#CE0000')}</div>"
|
||||
elif ext['status'] == 6:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Just discovered'>{ui_symbols.svg_bullet.style('#AEAEAE')}</div>"
|
||||
status = f"<div {style} title='Just discovered'>{ui_symbols.svg_bullet.style('#AEAEAE')}</div>"
|
||||
else:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Unknown status'>{ui_symbols.svg_bullet.style('#008EBC')}</div>"
|
||||
status = f"<div {style} title='Unknown status'>{ui_symbols.svg_bullet.style('#008EBC')}</div>"
|
||||
else:
|
||||
if updated < datetime.now(timezone.utc) - timedelta(6*30): # TZ-aware
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='Unmaintained'>{ui_symbols.svg_bullet.style('#C000CF')}</div>"
|
||||
status = f"<div {style} title='Unmaintained'>{ui_symbols.svg_bullet.style('#C000CF')}</div>"
|
||||
else:
|
||||
status = f"<div style='cursor:help;width:1rem;margin:auto;' title='No info'>{ui_symbols.svg_bullet.style('#7C7C7C')}</div>"
|
||||
status = f"<div {style} title='No info'>{ui_symbols.svg_bullet.style('#7C7C7C')}</div>"
|
||||
|
||||
code += f"""
|
||||
<tr style="display: {visible}">
|
||||
|
||||
Reference in New Issue
Block a user