From 0e4640a9167cf0d71ec9faea3f1d3edbf5a8472c Mon Sep 17 00:00:00 2001 From: mozman Date: Sun, 17 Dec 2023 10:42:38 +0100 Subject: [PATCH] change project structure --- .gitignore | 5 ++++- .vscode/settings.json | 5 ----- apply_sdxl_style.py | 9 +++++++-- .../art_styles_expansion.json | 15 +++++---------- .../clipdrop_styles.json | 5 ----- fooocus.json => styles/fooocus.json | 5 ----- .../sdxl_styles_mre.json | 5 ----- .../sdxl_styles_sai.json | 5 ----- .../sdxl_styles_twri.json | 5 ----- .../technical_documentation.json | 7 +------ test_apply_sdxl_styles.py | 9 +++++++-- 11 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 .vscode/settings.json rename art_styles_expansion.json => styles/art_styles_expansion.json (98%) rename clipdrop_styles.json => styles/clipdrop_styles.json (97%) rename fooocus.json => styles/fooocus.json (97%) rename sdxl_styles_mre.json => styles/sdxl_styles_mre.json (98%) rename sdxl_styles_sai.json => styles/sdxl_styles_sai.json (98%) rename sdxl_styles_twri.json => styles/sdxl_styles_twri.json (99%) rename technical_documentation.json => styles/technical_documentation.json (92%) diff --git a/.gitignore b/.gitignore index ba0430d..d981f61 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -__pycache__/ \ No newline at end of file +__pycache__/ +.mypy_cache/ +.pytest_cache/ +.vscode/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 19c797f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "cSpell.words": [ - "twri" - ] -} \ No newline at end of file diff --git a/apply_sdxl_style.py b/apply_sdxl_style.py index f519de0..954f3c7 100644 --- a/apply_sdxl_style.py +++ b/apply_sdxl_style.py @@ -50,6 +50,7 @@ def load_style_templates(style_path: pathlib.Path) -> dict[str, Template]: negative_prompt=record.get("negative_prompt", ""), ) templates[template.name] = template + templates[BYPASS] = BYPASS_TEMPLATE return templates @@ -63,7 +64,10 @@ class ApplyStyle: @classmethod def INPUT_TYPES(self): style_names = sorted(self.TEMPLATES.keys()) - style_names.remove(BYPASS) + try: + style_names.remove(BYPASS) + except ValueError: + pass style_names.insert(0, BYPASS) return { @@ -127,13 +131,14 @@ NODE_DEFINITIONS = [ ("clipdrop_styles.json", "Apply ClipDrop Style"), ("fooocus.json", "Apply Fooocus Style"), ("art_styles_expansion.json", "Apply Art Style Expansion"), + ("technical_documentation.json", "Apply Technical Documentation Style"), ] def _setup_classes(): cwd = pathlib.Path(__file__).parent for file_name, display_name in NODE_DEFINITIONS: - templates = load_style_templates(cwd / file_name) + templates = load_style_templates(cwd / "styles" / file_name) class_name = display_name.replace(" ", "") # create classes dynamically: diff --git a/art_styles_expansion.json b/styles/art_styles_expansion.json similarity index 98% rename from art_styles_expansion.json rename to styles/art_styles_expansion.json index fc85d0e..e8cc3b8 100644 --- a/art_styles_expansion.json +++ b/styles/art_styles_expansion.json @@ -1,9 +1,4 @@ [ - { - "name": "bypass", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "Abstract Expressionism", "prompt": "Abstract Expressionism {prompt} , High contrast, minimalistic, colorful, stark, dramatic, expressionism", @@ -45,8 +40,8 @@ "negative_prompt": "ugly, deformed, noisy, blurry, low contrast" }, { - "name": "Avant-garde", - "prompt": "Avant-garde {prompt} , unusual, experimental, avant-garde art", + "name": "Avantgarde", + "prompt": "Avantgarde {prompt} , unusual, experimental, avantgarde art", "negative_prompt": "ugly, deformed, noisy, blurry, low contrast" }, { @@ -231,7 +226,7 @@ }, { "name": "Knolling Photography", - "prompt": "Knolling Photography {prompt} , flat lay photography, object arrangment, knolling photography", + "prompt": "Knolling Photography {prompt} , flat lay photography, object arrangement, knolling photography", "negative_prompt": "ugly, deformed, noisy, blurry, low contrast" }, { @@ -261,7 +256,7 @@ }, { "name": "Marker Drawing", - "prompt": "Marker Drawing {prompt} , bold marker lines, visibile paper texture, marker drawing", + "prompt": "Marker Drawing {prompt} , bold marker lines, visible paper texture, marker drawing", "negative_prompt": "ugly, deformed, noisy, blurry, low contrast, photograph, realistic" }, { @@ -276,7 +271,7 @@ }, { "name": "Neo-Baroque", - "prompt": "Neo-Baroque {prompt} , ornate and elaborate, dynaimc, Neo-Baroque", + "prompt": "Neo-Baroque {prompt} , ornate and elaborate, dynamic, Neo-Baroque", "negative_prompt": "ugly, deformed, noisy, blurry, low contrast" }, { diff --git a/clipdrop_styles.json b/styles/clipdrop_styles.json similarity index 97% rename from clipdrop_styles.json rename to styles/clipdrop_styles.json index eff4708..40c30ae 100644 --- a/clipdrop_styles.json +++ b/styles/clipdrop_styles.json @@ -1,9 +1,4 @@ [ - { - "name": "bypass", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "Anime", "prompt": "anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed", diff --git a/fooocus.json b/styles/fooocus.json similarity index 97% rename from fooocus.json rename to styles/fooocus.json index aed3b97..81d6442 100644 --- a/fooocus.json +++ b/styles/fooocus.json @@ -1,9 +1,4 @@ [ - { - "name": "bypass", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "Fooocus Enhance", "negative_prompt": "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name:1.2), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, (airbrushed, cartoon, anime, semi-realistic, cgi, render, blender, digital art, manga, amateur:1.3), (3D ,3D Game, 3D Game Scene, 3D Character:1.1), (bad hands, bad anatomy, bad body, bad face, bad teeth, bad arms, bad legs, deformities:1.3)" diff --git a/sdxl_styles_mre.json b/styles/sdxl_styles_mre.json similarity index 98% rename from sdxl_styles_mre.json rename to styles/sdxl_styles_mre.json index 67d4d92..c18c310 100644 --- a/sdxl_styles_mre.json +++ b/styles/sdxl_styles_mre.json @@ -1,9 +1,4 @@ [ - { - "name": "bypass", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "mre-cinematic-dynamic", "prompt": "epic cinematic shot of dynamic {prompt} in motion. main subject of high budget action movie. raw photo, motion blur. best quality, high resolution", diff --git a/sdxl_styles_sai.json b/styles/sdxl_styles_sai.json similarity index 98% rename from sdxl_styles_sai.json rename to styles/sdxl_styles_sai.json index be039f7..a705b24 100644 --- a/sdxl_styles_sai.json +++ b/styles/sdxl_styles_sai.json @@ -1,9 +1,4 @@ [ - { - "name": "bypass", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "sai-3d-model", "prompt": "professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting", diff --git a/sdxl_styles_twri.json b/styles/sdxl_styles_twri.json similarity index 99% rename from sdxl_styles_twri.json rename to styles/sdxl_styles_twri.json index ef008ee..687a19d 100644 --- a/sdxl_styles_twri.json +++ b/styles/sdxl_styles_twri.json @@ -1,9 +1,4 @@ [ - { - "name": "bypass", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "ads-advertising", "prompt": "advertising poster style {prompt} . Professional, modern, product-focused, commercial, eye-catching, highly detailed", diff --git a/technical_documentation.json b/styles/technical_documentation.json similarity index 92% rename from technical_documentation.json rename to styles/technical_documentation.json index 0576ac9..06dcc2f 100644 --- a/technical_documentation.json +++ b/styles/technical_documentation.json @@ -1,9 +1,4 @@ [ - { - "name": "base", - "prompt": "{prompt}", - "negative_prompt": "" - }, { "name": "Architecture Blueprint", "prompt": "(floor plan: 1.1) architectural sketch style {prompt} . blueprint, oblique, draft, grayscale, flat, scale bars, monochromatic, annotation, hatching", @@ -27,7 +22,7 @@ { "name": "Landscape Plan", "prompt": "sketch style landscape plan, (site analysis:1.2), {prompt} (plan view:1.2), draft, hand-drawn, flat, hatching", - "negative_prompt": "pencil, hand, messy, 3D model, photo, realistic, brush, isometric, perpective, text" + "negative_prompt": "pencil, hand, messy, 3D model, photo, realistic, brush, isometric, perspective, text" }, { "name": "Mechanical Sketch", diff --git a/test_apply_sdxl_styles.py b/test_apply_sdxl_styles.py index cb171d0..a13ba3d 100644 --- a/test_apply_sdxl_styles.py +++ b/test_apply_sdxl_styles.py @@ -1,4 +1,4 @@ -# Copyright (c) , Manfred Moitzi +# Copyright (c) 2023, Manfred Moitzi # License: MIT License import pytest import re @@ -23,7 +23,12 @@ def test_valid_class_names(): def test_classes_have_templates(): for cls in NODE_CLASS_MAPPINGS.values(): - assert len(cls.TEMPLATES) > 1 + assert len(cls.TEMPLATES) > 1, "no styles loaded - correct filename?" + +def test_templates_have_bypass_style(): + """The style "bypass" will be added automatically to every style file.""" + for cls in NODE_CLASS_MAPPINGS.values(): + assert "bypass" in cls.TEMPLATES, "required 'bypass' style not found" if __name__ == "__main__":