From 5386b1c75e24afaf2057da96d95cd79ed816925b Mon Sep 17 00:00:00 2001 From: justumen Date: Tue, 17 Sep 2024 22:31:57 +0200 Subject: [PATCH] 0.40 --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++ loop_write_text.py | 18 +++++++++++++++-- pyproject.toml | 2 +- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ebf0e4..2203eaa 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,54 @@ If you have any issues with this template from Runpod, please let me know, I'm h - `pip install ollama` (you can also install ollama if you want : https://ollama.com/download) - You don't need to really install it if you don't want to use my ollama node. (BUT you need to run `pip install ollama`) - `pip install pydub` (for TTS node) +# Nodes menu + +1. [πŸ‘ Show (Text, Int, Float)](#1---πŸ‘-show-text-int-float) +2. [βœ’ Write Text](#2---βœ’-write-text) +3. [βœ’πŸ—” Advanced Write Text (random selection and variables)](#3---βœ’πŸ—”-advanced-write-text-random-selection-and-variables) +4. [πŸ”— Combine Texts](#4---πŸ”—-combine-texts) +5. [🎲 Random (Texts)](#5---🎲-random-texts) +6. [β™» Loop](#6---β™»-loop) +7. [β™» Loop Texts](#7---β™»-loop-texts) +8. [β™» Loop Integer](#8---β™»-loop-integer) +9. [β™» Loop Float](#9---β™»-loop-float) +10. [β™» Loop All Samplers](#10---β™»-loop-all-samplers) +11. [β™» Loop All Schedulers](#11---β™»-loop-all-schedulers) +12. [β™» Loop Combos](#12---β™»-loop-combos) +13. [πŸ“ Resize Exact](#13---πŸ“-resize-exact) +14. [πŸ–Ό Save Exact name](#14---πŸ–Ό-save-exact-name) +15. [πŸ’Ύ Save Text](#15---πŸ’Ύ-save-text) +16. [πŸ–ΌπŸ’¬ Save image for Bjornulf LobeChat](#16---πŸ–ΌπŸ’¬-save-image-for-bjornulf-lobechat) +17. [πŸ–Ό Save image as `tmp_api.png` Temporary API](#17---πŸ–Ό-save-image-as-tmp_apipng-temporary-api) +18. [πŸ–ΌπŸ“ Save image to a chosen folder name](#18---πŸ–ΌπŸ“-save-image-to-a-chosen-folder-name) +19. [πŸ¦™ Ollama](#19---πŸ¦™-ollama) +20. [πŸ“Ή Video Ping Pong](#20---πŸ“Ή-video-ping-pong) +21. [πŸ“Ή Images to Video](#21---πŸ“Ή-images-to-video) +22. [πŸ”² Remove image Transparency (alpha)](#22---πŸ”²-remove-image-transparency-alpha) +23. [πŸ”² Image to grayscale (black & white)](#23---πŸ”²-image-to-grayscale-black--white) +24. [πŸ–Ό+πŸ–Ό Combine images (Background + Overlay)](#24---πŸ–ΌπŸ–Ό-combine-images-background--overlay) +25. [πŸŸ©βžœβ–’ Green Screen to Transparency](#25---πŸŸ©βžœβ–’-green-screen-to-transparency) +26. [🎲 Random line from input](#26---🎲-random-line-from-input) +27. [β™» Loop (All Lines from input)](#27---β™»-loop-all-lines-from-input) +28. [πŸ”’ Text with random Seed](#28---πŸ”’-text-with-random-seed) +29. [πŸ–Ό Load Image with Transparency β–’](#29---πŸ–Ό-load-image-with-transparency-β–’) +30. [πŸ–Όβœ‚ Cut image with a mask](#30---πŸ–Όβœ‚-cut-image-with-a-mask) +31. [πŸ”Š TTS - Text to Speech](#31---πŸ”Š-tts---text-to-speech) +32. [πŸ§‘πŸ“ Character Description Generator](#32---πŸ§‘πŸ“-character-description-generator) +33. [β™» Loop (All Lines from input πŸ”— combine by lines)](#33---β™»-loop-all-lines-from-input-πŸ”—-combine-by-lines) +34. [🧹 Free VRAM hack](#34---🧹-free-vram-hack) +35. [⏸️ Paused. Resume or Stop ?](#35---⏸️-paused-resume-or-stop-) +36. [βΈοΈπŸ” Paused. Select input, Pick one](#36---βΈοΈπŸ”-paused-select-input-pick-one) +37. [πŸŽ²πŸ–Ό Random Image](#37---πŸŽ²πŸ–Ό-random-image) +38. [β™»πŸ–Ό Loop (Images)](#38---β™»πŸ–Ό-loop-images) +39. [β™» Loop (βœ’πŸ—” Advanced Write Text)](#39---β™»-loop-βœ’πŸ—”-advanced-write-text) +40. [🎲 Random (Model+Clip+Vae) - aka Checkpoint / Model](#40---🎲-random-modelclipvae---aka-checkpoint--model) +41. [🎲 Random Load checkpoint (Model Selector)](#41---🎲-random-load-checkpoint-model-selector) +42. [β™» Loop (Model+Clip+Vae) - aka Checkpoint / Model](#42---β™»-loop-modelclipvae---aka-checkpoint--model) +43. [πŸ“‚πŸ–Ό Load Images from output folder](#43---πŸ“‚πŸ–Ό-load-images-from-output-folder) +44. [πŸ–ΌπŸ” Select an Image, Pick](#44---πŸ–ΌπŸ”-select-an-image-pick) +45. [πŸ”€ If-Else (input == compare_with)](#45---πŸ”€-if-else-input--compare_with) + # πŸ“ Changelog - **v0.2**: Improve ollama node with system prompt + model selection. @@ -91,6 +139,7 @@ If you have any issues with this template from Runpod, please let me know, I'm h - **v0.37**: New node : Random Load checkpoint (Model Selector). Alternative to the random checkpoint node. (Not preloading all checkpoints in memory, slower to switch between checkpoints, but more outputs to decide where to store your results.) - **v0.38**: New node : If-Else logic. (input == compare_with), examples with different latent space size. +fix some deserialization issues. - **v0.39**: Add variables management to Advanced Write Text node. +- **v0.40**: Add variables management to Loop Advanced Write Text node. Add menu for all nodes to the README. # πŸ“ Nodes descriptions @@ -469,6 +518,7 @@ Above is an example of the loop images node sending them to an Ipadapter workflo **Description:** If you need a quick loop but you don't want something too complex with a loop node, you can use this combined write text + loop. It will take the same special syntax as the Advanced write text node `{blue|red}`, but it will loop over ALL the possibilities instead of taking one at random. +0.40 : You can also use variables `` in the loop. ### 40 - 🎲 Random (Model+Clip+Vae) - aka Checkpoint / Model diff --git a/loop_write_text.py b/loop_write_text.py index 43f0eb6..c25e2ee 100644 --- a/loop_write_text.py +++ b/loop_write_text.py @@ -8,6 +8,9 @@ class LoopWriteText: "required": { "text": ("STRING", {"multiline": True}), }, + "optional": { + "variables": ("STRING", {"forceInput": True}), + } } RETURN_TYPES = ("STRING",) @@ -17,7 +20,18 @@ class LoopWriteText: OUTPUT_IS_LIST = (True,) CATEGORY = "Bjornulf" - def loop_write_text(self, text): + def loop_write_text(self, text, variables=""): + # Parse variables + var_dict = {} + for line in variables.split('\n'): + if '=' in line: + key, value = line.strip().split('=', 1) + var_dict[key.strip()] = value.strip() + + # Replace variables in the text + for key, value in var_dict.items(): + text = text.replace(f"<{key}>", value) + pattern = r'\{([^}]+)\}' matches = re.findall(pattern, text) @@ -37,5 +51,5 @@ class LoopWriteText: return (results,) @classmethod - def IS_CHANGED(s, text): + def IS_CHANGED(s, text, variables=""): return float("nan") # Always re-execute to ensure consistency \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 0e43a49..e7009c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "bjornulf_custom_nodes" description = "Nodes: Ollama, Text to Speech, Combine Texts, Random Texts, Save image for Bjornulf LobeChat, Text with random Seed, Random line from input, Combine images, Image to grayscale (black & white), Remove image Transparency (alpha), Resize Image, ..." -version = "0.39" +version = "0.40" license = {file = "LICENSE"} [project.urls]