diff --git a/__init__.py b/__init__.py index f20ad32..59662ea 100644 --- a/__init__.py +++ b/__init__.py @@ -18,7 +18,7 @@ logger = logging.getLogger('AnimaginePrompt') NODE_DIR = os.path.dirname(os.path.realpath(__file__)) SAMPLE_DATA_DIR = os.path.join(NODE_DIR, "sample_data") -# Ensure the sample_data directory exists +# Ensure the sample_data directory exists within the node directory if not os.path.exists(SAMPLE_DATA_DIR): os.makedirs(SAMPLE_DATA_DIR) @@ -45,4 +45,4 @@ WEB_DIRECTORY = "./web" define_routes() logger.info("[Animagine Prompt] API routes initialized") -__version__ = "1.6.0" +__version__ = "1.6.1" diff --git a/example_workflow/example_wildcards_workflow.json b/example_workflow/example_wildcards_workflow.json index 723691d..8e76461 100644 --- a/example_workflow/example_wildcards_workflow.json +++ b/example_workflow/example_wildcards_workflow.json @@ -1,8 +1,8 @@ { "id": "9fbd8184-60f6-4220-99d4-158e36d43551", "revision": 0, - "last_node_id": 19, - "last_link_id": 15, + "last_node_id": 21, + "last_link_id": 19, "nodes": [ { "id": 2, @@ -37,7 +37,7 @@ "widgets_values": [ "A {red|blue|green} dog", true, - 4292686539, + 3143738042, "randomize" ] }, @@ -74,10 +74,10 @@ "cnr_id": "comfyui-display-value", "ver": "1.0.3", "Node name for S&R": "DisplayValue", - "preview": "A blue dog" + "preview": "A green dog" }, "widgets_values": [ - "A blue dog" + "A green dog" ] }, { @@ -113,10 +113,88 @@ "cnr_id": "comfyui-display-value", "ver": "1.0.3", "Node name for S&R": "DisplayValue", - "preview": "gentle" + "preview": "playful" }, "widgets_values": [ - "gentle" + "playful" + ] + }, + { + "id": 19, + "type": "DisplayValue", + "pos": [ + 1979.81884765625, + 488.3630676269531 + ], + "size": [ + 210, + 88 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "value", + "type": "*", + "link": 19 + } + ], + "outputs": [ + { + "name": "STRING", + "shape": 6, + "type": "STRING", + "links": null + } + ], + "properties": { + "cnr_id": "comfyui-display-value", + "ver": "1.0.3", + "Node name for S&R": "DisplayValue", + "preview": "energetic standing wearing vintage clothing in a office building" + }, + "widgets_values": [ + "energetic standing wearing vintage clothing in a office building" + ] + }, + { + "id": 18, + "type": "DisplayValue", + "pos": [ + 1979.81884765625, + 262 + ], + "size": [ + 210, + 88 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "value", + "type": "*", + "link": 18 + } + ], + "outputs": [ + { + "name": "STRING", + "shape": 6, + "type": "STRING", + "links": null + } + ], + "properties": { + "cnr_id": "comfyui-display-value", + "ver": "1.0.3", + "Node name for S&R": "DisplayValue", + "preview": "energetic standing wearing vintage clothing in a office building" + }, + "widgets_values": [ + "energetic standing wearing vintage clothing in a office building" ] }, { @@ -150,22 +228,22 @@ "Node name for S&R": "TextFileLoader" }, "widgets_values": [ - "wildcards\\expressions.txt", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\expressions.txt", -1, - 947005830, + 353433227, "randomize" ] }, { - "id": 11, + "id": 21, "type": "MultiWildcardLoader", "pos": [ - 1517.909423828125, - 262 + 1513.4754638671875, + 260.9877624511719 ], "size": [ 400, - 540 + 564 ], "flags": {}, "order": 2, @@ -176,121 +254,44 @@ "name": "combined_text", "type": "STRING", "links": [ - 14 + 18 ] }, { "name": "preview_text", "type": "STRING", "links": [ - 15 + 19 ] } ], "properties": { "cnr_id": "animagine-prompt", - "ver": "8734c5115cbde087660d835dfe3a6c63ebcb7d49", + "ver": "06cfdf420f461a597dd52c9b7c4163741bccb93b", "Node name for S&R": "MultiWildcardLoader" }, "widgets_values": [ "template", - "{expressions.txt} {poses.txt} wearing {clothing.txt} in a {scenarios.txt}", + "{custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\expressions.txt} {custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\poses.txt} wearing {custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\clothing.txt} in a {custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\scenarios.txt}", ", ", - -1, - "", + 3116681983, + "randomize", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\expressions.txt", true, -1, - "", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\poses.txt", true, -1, - "", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\clothing.txt", true, -1, - "", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\scenarios.txt", true, -1, "", true, -1 ] - }, - { - "id": 19, - "type": "DisplayValue", - "pos": [ - 1979.81884765625, - 488.3630676269531 - ], - "size": [ - 210, - 88 - ], - "flags": {}, - "order": 6, - "mode": 0, - "inputs": [ - { - "name": "value", - "type": "*", - "link": 15 - } - ], - "outputs": [ - { - "name": "STRING", - "shape": 6, - "type": "STRING", - "links": null - } - ], - "properties": { - "cnr_id": "comfyui-display-value", - "ver": "1.0.3", - "Node name for S&R": "DisplayValue", - "preview": "confident stretching wearing winter coat in a busy cafe" - }, - "widgets_values": [ - "confident stretching wearing winter coat in a busy cafe" - ] - }, - { - "id": 18, - "type": "DisplayValue", - "pos": [ - 1979.81884765625, - 262 - ], - "size": [ - 210, - 88 - ], - "flags": {}, - "order": 5, - "mode": 0, - "inputs": [ - { - "name": "value", - "type": "*", - "link": 14 - } - ], - "outputs": [ - { - "name": "STRING", - "shape": 6, - "type": "STRING", - "links": null - } - ], - "properties": { - "cnr_id": "comfyui-display-value", - "ver": "1.0.3", - "Node name for S&R": "DisplayValue", - "preview": "confident stretching wearing winter coat in a busy cafe" - }, - "widgets_values": [ - "confident stretching wearing winter coat in a busy cafe" - ] } ], "links": [ @@ -311,16 +312,16 @@ "*" ], [ - 14, - 11, + 18, + 21, 0, 18, 0, "*" ], [ - 15, - 11, + 19, + 21, 1, 19, 0, @@ -334,15 +335,15 @@ "scale": 1.1000000000000005, "offset": [ -683.4754456662796, - -115.53322860460348 + -116.44231951369439 ] }, + "frontendVersion": "1.23.4", "node_versions": { "ComfyUI-Jjk-Nodes": "b3c99bb78a99551776b5eab1a820e1cd58f84f31", "ComfyUI-Animagine-prompt": "4f0855ce259ac48ae59468d4ce5a8b726a8b2923" }, - "ue_links": [], - "frontendVersion": "1.23.4" + "ue_links": [] }, "version": 0.4 } \ No newline at end of file diff --git a/example_workflow/example_wildcards_workflow.png b/example_workflow/example_wildcards_workflow.png new file mode 100644 index 0000000..b6a3eed Binary files /dev/null and b/example_workflow/example_wildcards_workflow.png differ diff --git a/example_workflow/example_workflow.json b/example_workflow/example_workflow.json index de1d03e..262ae57 100644 --- a/example_workflow/example_workflow.json +++ b/example_workflow/example_workflow.json @@ -1,48 +1,9 @@ { "id": "82357ebe-40e9-4beb-b9f5-097ab9863b04", "revision": 0, - "last_node_id": 22, - "last_link_id": 16, + "last_node_id": 24, + "last_link_id": 20, "nodes": [ - { - "id": 17, - "type": "DisplayValue", - "pos": [ - 1837.260009765625, - 215.26971435546875 - ], - "size": [ - 210, - 88 - ], - "flags": {}, - "order": 7, - "mode": 0, - "inputs": [ - { - "name": "value", - "type": "*", - "link": 11 - } - ], - "outputs": [ - { - "name": "STRING", - "shape": 6, - "type": "STRING", - "links": null - } - ], - "properties": { - "cnr_id": "comfyui-display-value", - "ver": "1.0.3", - "Node name for S&R": "DisplayValue", - "preview": "confident stretching wearing winter coat in a busy cafe" - }, - "widgets_values": [ - "confident stretching wearing winter coat in a busy cafe" - ] - }, { "id": 18, "type": "DisplayValue", @@ -55,13 +16,13 @@ 88 ], "flags": {}, - "order": 4, + "order": 5, "mode": 0, "inputs": [ { "name": "value", "type": "*", - "link": 12 + "link": 17 } ], "outputs": [ @@ -76,10 +37,10 @@ "cnr_id": "comfyui-display-value", "ver": "1.0.3", "Node name for S&R": "DisplayValue", - "preview": "1girl, carro pino, .live, safe, your awesome prompt, masterpiece, best quality, absurdres, high score, great score, good score" + "preview": "1girl, carro pino, .live, masterpiece, best quality, absurdres, high score, great score, good score" }, "widgets_values": [ - "1girl, carro pino, .live, safe, your awesome prompt, masterpiece, best quality, absurdres, high score, great score, good score" + "1girl, carro pino, .live, masterpiece, best quality, absurdres, high score, great score, good score" ] }, { @@ -94,13 +55,13 @@ 88 ], "flags": {}, - "order": 5, + "order": 6, "mode": 0, "inputs": [ { "name": "value", "type": "*", - "link": 13 + "link": 18 } ], "outputs": [ @@ -115,10 +76,10 @@ "cnr_id": "comfyui-display-value", "ver": "1.0.3", "Node name for S&R": "DisplayValue", - "preview": "low quality, worst quality, blurry, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, artist name, the things that hurts your awesome prompt" + "preview": "low quality, worst quality, blurry, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, artist name" }, "widgets_values": [ - "low quality, worst quality, blurry, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, artist name, the things that hurts your awesome prompt" + "low quality, worst quality, blurry, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, jpeg artifacts, signature, watermark, username, artist name" ] }, { @@ -133,7 +94,7 @@ 88 ], "flags": {}, - "order": 6, + "order": 4, "mode": 0, "inputs": [ { @@ -193,67 +154,10 @@ "cnr_id": "comfyui-display-value", "ver": "1.0.3", "Node name for S&R": "DisplayValue", - "preview": "relaxed" + "preview": "cool" }, "widgets_values": [ - "relaxed" - ] - }, - { - "id": 11, - "type": "AnimaginePrompt", - "pos": [ - -10, - 215.26971435546875 - ], - "size": [ - 400, - 503 - ], - "flags": {}, - "order": 0, - "mode": 0, - "inputs": [], - "outputs": [ - { - "name": "POSITIVE_PROMPT", - "type": "STRING", - "slot_index": 0, - "links": [ - 12 - ] - }, - { - "name": "NEGATIVE_PROMPT", - "type": "STRING", - "slot_index": 1, - "links": [ - 13 - ] - } - ], - "properties": { - "cnr_id": "animagine-prompt", - "ver": "8734c5115cbde087660d835dfe3a6c63ebcb7d49", - "Node name for S&R": "AnimaginePrompt" - }, - "widgets_values": [ - "your awesome prompt", - "the things that hurts your awesome prompt", - true, - "example.csv", - 0, - true, - "safe", - true, - "masterpiece, best quality, absurdres", - "high score, great score, good score", - false, - "low quality, worst quality", - "average score, bad score, low score", - false, - 2024, - 2024 + "cool" ] }, { @@ -268,7 +172,7 @@ 200 ], "flags": {}, - "order": 1, + "order": 0, "mode": 0, "inputs": [], "outputs": [ @@ -289,7 +193,7 @@ "widgets_values": [ "A {red|blue|green} dog", true, - 196340664, + 321698759, "randomize" ] }, @@ -311,7 +215,7 @@ { "name": "value", "type": "*", - "link": 16 + "link": 20 } ], "outputs": [ @@ -326,14 +230,108 @@ "cnr_id": "comfyui-display-value", "ver": "1.0.3", "Node name for S&R": "DisplayValue", - "preview": "confident stretching wearing winter coat in a busy cafe" + "preview": "warm jumping wearing flowing skirt in a art gallery" }, "widgets_values": [ - "confident stretching wearing winter coat in a busy cafe" + "warm jumping wearing flowing skirt in a art gallery" ] }, { - "id": 16, + "id": 23, + "type": "AnimaginePrompt", + "pos": [ + -10, + 215.26971435546875 + ], + "size": [ + 400, + 498 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "POSITIVE_PROMPT", + "type": "STRING", + "links": [ + 17 + ] + }, + { + "name": "NEGATIVE_PROMPT", + "type": "STRING", + "links": [ + 18 + ] + } + ], + "properties": { + "cnr_id": "animagine-prompt", + "ver": "06cfdf420f461a597dd52c9b7c4163741bccb93b", + "Node name for S&R": "AnimaginePrompt" + }, + "widgets_values": [ + "", + "", + true, + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\example.csv", + null, + 0, + false, + "safe", + true, + "masterpiece, best quality, absurdres", + "high score, great score, good score", + false, + "low quality, worst quality", + "average score, bad score, low score", + false, + 2024 + ] + }, + { + "id": 17, + "type": "DisplayValue", + "pos": [ + 1837.260009765625, + 215.26971435546875 + ], + "size": [ + 210, + 88 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "value", + "type": "*", + "link": 19 + } + ], + "outputs": [ + { + "name": "STRING", + "shape": 6, + "type": "STRING", + "links": null + } + ], + "properties": { + "cnr_id": "comfyui-display-value", + "ver": "1.0.3", + "Node name for S&R": "DisplayValue", + "preview": "warm jumping wearing flowing skirt in a art gallery" + }, + "widgets_values": [ + "warm jumping wearing flowing skirt in a art gallery" + ] + }, + { + "id": 24, "type": "MultiWildcardLoader", "pos": [ 1391.8079833984375, @@ -352,42 +350,42 @@ "name": "combined_text", "type": "STRING", "links": [ - 11 + 19 ] }, { "name": "preview_text", "type": "STRING", "links": [ - 16 + 20 ] } ], "properties": { "cnr_id": "animagine-prompt", - "ver": "8734c5115cbde087660d835dfe3a6c63ebcb7d49", + "ver": "06cfdf420f461a597dd52c9b7c4163741bccb93b", "Node name for S&R": "MultiWildcardLoader" }, "widgets_values": [ "template", - "{expressions.txt} {poses.txt} wearing {clothing.txt} in a {scenarios.txt}", + "{custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\expressions.txt} {custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\poses.txt} wearing {custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\clothing.txt} in a {custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\scenarios.txt}", ", ", + 365623469, + "randomize", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\expressions.txt", + true, -1, - "", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\poses.txt", + true, + -1, + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\clothing.txt", + true, + -1, + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\scenarios.txt", true, -1, "", true, - -1, - "", - true, - -1, - "", - true, - -1, - "", - true, - -1, -1 ] }, @@ -422,38 +420,14 @@ "Node name for S&R": "TextFileLoader" }, "widgets_values": [ - "wildcards\\expressions.txt", + "custom_nodes\\ComfyUI-Animagine-Prompt\\example_files\\expressions.txt", -1, - 4006281810, + 3980484292, "randomize" ] } ], "links": [ - [ - 11, - 16, - 0, - 17, - 0, - "*" - ], - [ - 12, - 11, - 0, - 18, - 0, - "*" - ], - [ - 13, - 11, - 1, - 19, - 0, - "*" - ], [ 14, 2, @@ -471,8 +445,32 @@ "*" ], [ - 16, - 16, + 17, + 23, + 0, + 18, + 0, + "*" + ], + [ + 18, + 23, + 1, + 19, + 0, + "*" + ], + [ + 19, + 24, + 0, + 17, + 0, + "*" + ], + [ + 20, + 24, 1, 22, 0, @@ -485,8 +483,8 @@ "ds": { "scale": 0.8264462809917354, "offset": [ - 110, - -115.26971435546875 + 49.09028925619825, + 33.110988123870136 ] }, "frontendVersion": "1.23.4", diff --git a/example_workflow/example_workflow.png b/example_workflow/example_workflow.png index 84a6701..0e456e4 100644 Binary files a/example_workflow/example_workflow.png and b/example_workflow/example_workflow.png differ diff --git a/logger.py b/logger.py index 4b0dfeb..1248dab 100644 --- a/logger.py +++ b/logger.py @@ -7,13 +7,17 @@ import os from datetime import datetime from typing import Optional, Dict, Any +# Get the directory where this module is located +NODE_DIR = os.path.dirname(os.path.realpath(__file__)) + class AnimagineLogger: """ Custom logger for the Animagine Prompt Node with enhanced debugging capabilities """ def __init__(self, log_dir: str = "logs"): - self.log_dir = log_dir + # Use absolute path relative to the node directory + self.log_dir = os.path.join(NODE_DIR, log_dir) self.logger = None self.setup_logger() diff --git a/node.zip b/node.zip index a971b96..9aef6c7 100644 Binary files a/node.zip and b/node.zip differ diff --git a/pyproject.toml b/pyproject.toml index d986935..4a74f92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "animagine-prompt" description = "Comfy UI node to prompt build for https://huggingface.co/cagliostrolab/animagine-xl-4.0 model " -version = "1.6.0" +version = "1.6.1" license = {file = "LICENSE"} [project.urls] diff --git a/state_manager.py b/state_manager.py index 0680958..a13e0fe 100644 --- a/state_manager.py +++ b/state_manager.py @@ -8,15 +8,19 @@ from typing import Dict, Any, Optional from datetime import datetime from .logger import logger +# Get the directory where this module is located +NODE_DIR = os.path.dirname(os.path.realpath(__file__)) + class StateManager: """ Manages the persistence and restoration of node states """ def __init__(self, config_dir: str = "config"): - self.config_dir = config_dir - self.state_file = os.path.join(config_dir, "animagine_state.json") - self.history_file = os.path.join(config_dir, "csv_history.json") + # Use absolute path relative to the node directory + self.config_dir = os.path.join(NODE_DIR, config_dir) + self.state_file = os.path.join(self.config_dir, "animagine_state.json") + self.history_file = os.path.join(self.config_dir, "csv_history.json") self.current_state: Dict[str, Any] = {} self.csv_history: Dict[str, Dict[str, Any]] = {} self._initialize()