Skip to content

Commit

Permalink
Add tile prompting editor in McBoaty v4 (#94)
Browse files Browse the repository at this point in the history
* Create README.md

* Hotfix image and mask output

* Update README.md

* Change architecture and start doc how to

* improve bus_fn function to be more dynamic & start web js files

* updae version to 1.1.0

* Initiate web extra menu node

* minor change in MANIFEST

* Move pythong base node to js

* inprogress refactorization of bus node in js

* attempt to assign in and out put - failed

* last attempt to make the node work via JS

* Implement py + js bus

* add back options menu

* update to latest attempt to pass dynamic entries through py node

* Initialize use of api to pass entries

* achieve to pass dynamic var to py node

* start implement profile - attempt 1

* implement proper profile system and identify node id on execution to apply proper profile

* stuck to continue as long as no node id available in bus_fn function

* modify id index

* add profile management on a node base

* remove console.log

* refactoring to appreciate better the execution order within the code

* todo troubleshoot the creation of none id json file

* hotfix empty node on creation

* fix some issues with add/remove inputs

* hotfix img in readme

* remove some useless console.log

* add stable universal bus node

* move busnode to universalbusnode

* add back classic BusNode and convert classname to Universal Bus Node for the dynamic one

* Deactivate UniversalBus and activate Bus and Pipe Basic Node - Bus is not working for some reason

* Add back UniversalBus try to debug the cache

* Merging regular PY Node with JS Node

* Add Bus + Pipe Basic node

* Add Details to build Detailer Pipe

* release of obsolete Bus_node + UniversalBusNode (py)

* Add AnyBusNode and change Helper Class for LiteGraphe in js

* keep developping the AnyBus by Implementing UniversalBus features

* Add synchronized inputs across all node of same default profile

* integrating previousInputName feature

* Implement Node Input Name Management on connect/disconnect

* set initial input to 15

* Implementation for nodeflowsync by profile - next implementation for profile widget to make the whole system work

* in process to assign profile name accross nodes of same flow

* fix profile management

* improving bus assignment based on profile - next make sure disconnected bus sync correctly

* fix input connect/disconnect population to same profile flow

* reach MVP to deliver

* switch widget number to combo

* quickfix

* Add support for Reroute type node in bus

* hotfix on support for reroute

* update a bit before testing why 2 links are addded on 1 connection

* hotfix syncNodes

* add normal workflow for issue 17

* link pass to null on reload

* default is now any not none

* improve non MarasitAnyBusNode node management (reroute)

* Deactivate the code on Initial load

* revert 18c9dad

* update readme for delivery, update max input number, update web flow to hotfix initial load from dnd flow

* Update some doc and version number

* Update some doc and version number

* enable to keep previous input setup on bus disconnect + add a clean button to reset unconnected input

* rename stuff for easier reading and add a refresh feature when cleaning

* hotfix refresh system for monoflow

* fix multiflow sync + allow only full sync

* fix profile name in flows which share same profile name but are no more connected

* fix input cleaning on multiflow

* add a cleaned label when cleaned

* fix overall cleaning process

* add console log if 2 flows have same names

* add console log if 2 flows have same names

* keep input/output on bus disconnect

* Update README.md

* Refactorize Js AnyBusNode

* Update Extension Name

* define all class as static class

* update how to retrieve and update flows

* clean sync process, add reroute node support

* Clean the custom node from previous code

* remove Native Reroute and pysssss Reroute from supported Reroute node

* hotfix for input removed even if used as output

* Update readme

* Update version number

* Update version number to avoid syntax error

* Add support for Get/Set node

* Add support for Get/Set node

* hotfix setNode issue

* Initiate Upscaler and add DisplayInfo node

* Beta test on Upscale node

* Beta test on Upscale node

* Beta test on Upscale node

* Beta test on Upscale node

* remove McBoaty

* add back Image class

* add back Image class

* hotfix rebuild_image_from_parts

* hotfix rebuilding image

* Implement the upscaling on a per grid image basis

* initiate applyin mask to grid image

* Upply mask to image

* add blank mask

* finalize the mask application

* add ksampler

* Set default value

* Update output

* Set default value

* Update Marasit_Nodes.py

* Update and rename UpscalerGridNode.py to UpscalerRefinerNode.py

* Update README.md

* hotfix node class name

* increase version number

* Implement VAEEncode/DecodeTiled

* Implement VAEEncode/DecodeTiled

* clean code

* clean code

* clean code

* clean code

* Add Sigmas_type management

* Update Version

* add AYS Scheduler

* Add log indicator for starting and finishing the McBoaty process

* add version to info + tiled condition

* add old Ksampler

* hotfix slow node

* hotfix slow node

* no hotfix for slow node

* Hotfix slowliness

* Improve log display

* Increment Version

* Update README.md

* hotfix anybus.js

* Add size feature, hidden iteration mecanism, log improvment

* Implement Version Number for nodes

* Implement McBoaty V2

* apply new grid system to Refiner

* apply new grid system to Refiner

* dynaminze the 16 grid & bring back the feather

* hotfix on grid16

* Add tiled images as output

* Update README.md

* Update README.md

* Update README.md

* Update MarasIT to MaraScott

* Update MarasIT to MaraScott

* update workflow png images

* add some more explaination to profile setting of bus node

* update version to 4.0.0

* not supported ControNet

* initiate node

* Add ComfyUI_LayerStyle dependencies

* add Was and Impact dependencies

* Update WAS dep

* Update WAS dep CONSTANT

* Update WAS - in progress

* Update inpainting process for masked area

* update noise_inpaint image

* add ImagePaste

* Update Inpainting Node to become 2 node steps

* integrate second node for inpaintingBymask

* integrate second node for inpaintingBymask

* integrate second node for inpaintingBymask

* integrate second node for inpaintingBymask

* Update V4.1.0

* Hotfix prompt on second node for inpainting (#58)

* Hotfix inpainting paste by mask (#61)

* Hotfix prompt on second node for inpainting

* Improve pasteByMask

* Improve pasteByMask

* Hotfix missing requirements.txt (#63)

* Hotfix prompt on second node for inpainting

* Improve pasteByMask

* Improve pasteByMask

* add requirements

* Feature node inpainting - beta test (#64)

* hotifx class conflict + add TokenCounter from ComfyUI-JNodes

* nodes maintenance - remove deprecated

* node maintenance hotfix + Kijai TokenCounter Node

* hotfix inpainting paste

* refactorize node to more OOP style

* remove deprecated node

* refactorize code

* apply correct mask to paste node but the source is not correct

* apply correct source

* apply correct source

* hotfix tile size and paste position

* hotfix paste by mask

* hotfix paint in noise blend

* initiate code for auto masking

* node inpainting beta version

* node inpainting beta version

* Feature node inpainting (#65)

* hotifx class conflict + add TokenCounter from ComfyUI-JNodes

* nodes maintenance - remove deprecated

* node maintenance hotfix + Kijai TokenCounter Node

* hotfix inpainting paste

* refactorize node to more OOP style

* remove deprecated node

* refactorize code

* apply correct mask to paste node but the source is not correct

* apply correct source

* apply correct source

* hotfix tile size and paste position

* hotfix paste by mask

* hotfix paint in noise blend

* initiate code for auto masking

* node inpainting beta version

* node inpainting beta version

* node inpainting beta version

* Feature node inpainting (#66)

* hotifx class conflict + add TokenCounter from ComfyUI-JNodes

* nodes maintenance - remove deprecated

* node maintenance hotfix + Kijai TokenCounter Node

* hotfix inpainting paste

* refactorize node to more OOP style

* remove deprecated node

* refactorize code

* apply correct mask to paste node but the source is not correct

* apply correct source

* apply correct source

* hotfix tile size and paste position

* hotfix paste by mask

* hotfix paint in noise blend

* initiate code for auto masking

* node inpainting beta version

* node inpainting beta version

* node inpainting beta version

* add padding to grow mask in pastInpaint

* add padding to grow mask in pastInpaint

* Add refiner to McInpainty

* Add refiner to McInpainty

* Feature Add Dynamic Tiling (#68)

* update McBoaty to more OOP approach

* Apply a refiner after upscaling + start dynamicaly define the number of tiles to refine

* refactoring and upgrading the grid system to be dynamic

* update grid system to order properly tile

* add inpainting vae encode

* Upgrade McBoaty to work with Dynamic Tiling for 4 tiles

* Correct rebuild system for dynamic tiling

* Hotfix tile assignment

* apply dynamiztion if the grid cutting sequence to retrieve the entire image and not only part of it

* removed middle tiles to identify issues, the tiles seems a little bit bigger than expected

* pursuing hotfix

* improving reinsertion of tiles in the grid

* fix image distribution

* fix feather display

* create McBoatyV3

* create McBoatyV3

* hotfix McBoatyV2

* hotfix mono image tile

* add McBoaty v3 + refactorize MS_image code for Version compatibility and modifying import

* Update code to allow Version for inc file MS_Image and MS_Mask

* Improve tile upscaling adding an extra feather on the left side or top side

* Update grid slicing to allow all type of ratio

* revise get_grid_image in case tile do not match original image size

* update rebuild process to handle any ratio images

* update to handle any ratio in image rebuilding process

* update outpainting sigmas denoise value to get image from outpainting

* revert to previous version of get_grid_images + hotfix on coordinate

* Add pyproject.toml for Custom Node Registry (#56)

* chore(pyproject): Add pyproject.toml for Custom Node Registry

* Update pyproject.toml

---------

Co-authored-by: MaraScott <[email protected]>

* chore(publish): Add Github Action for Publishing to Comfy Registry (#55)

* Update pyproject.toml (#69)

* Update pyproject.toml (#70)

* add LICENSE

* Hotfix mc boaty v3 (#71)

* hotfix to match UltimateSDUpscale field distribution and to fix bug if feather at 0

* update registry

* update registry for dependencies (#72)

* Hotfix registrylogo (#73)

* update registry for dependencies

* Update logo

* Add colorMatch to McBoaty (#74)

* Feature color match (#75)

* Add vendor KJNodes file

* Add vendor KJNodes file

* Add vendor KJNodes file

* Feature update color match default option (#76)

* add tile size for VAE

* add tile size for VAE

* remove tile size for vae, add none option for colorMatching

* remove tile size for vae to switch back to regular tile size

* fix the SD1 AYS model assignment (#77)

* Hotfix ays model type (#78)

* fix the SD1 AYS model assignment

* fix the SD1 AYS model assignment

* Feature mcboaty llm + new node McPrompty (#79)

* Update McBoaty Upscale Mechanism + add Per Tile Prompting generation + add new node to generate prompt from image

* hotfix llm vision name calling

* hotfix output size upscaling

* hotfix tiles order and execution duration display as int

* hotfix tiles order display and default llm model

* hotfix display index + default LLM Models list

* hotfix McPrompty name

* hotfix McPrompty name

* hotfix prestartup_script

* hotfix readme on tile prompting

* Hotfix multiratio upscale (#81)

* Update McBoaty Upscale Mechanism + add Per Tile Prompting generation + add new node to generate prompt from image

* hotfix llm vision name calling

* hotfix output size upscaling

* hotfix tiles order and execution duration display as int

* hotfix tiles order display and default llm model

* hotfix display index + default LLM Models list

* hotfix McPrompty name

* hotfix McPrompty name

* hotfix prestartup_script

* hotfix readme on tile prompting

* initiate square tiling + slicing after upscale

* squarify tiles for ksampling

* initiate forced square refining

* hotfix slicing tiles

* hotfix slicing tiles

* hotfix slicing tiles

* Implementing squared tiles upscaling

* hotfix xy coordinate crop if input file too small

* Hotfix llm prompt log (#82)

* hotfix prompt log issue

* hotfix prompt log issue

* Hotfix is divisible by 8 (#84)

* hotfix is_divisible_by_8

* hotfix is_divisible_by_8

* add McBoaty V4 2 node system

* add McBoaty TilePrompter

* ignore models in repo

* ignore models in repo

* add back vision, add florence-2, initiate prompt editor

* add dynamic js inputs

* Update Js for TilePrompter

* introduce the cache system

* add cache and api call

* make work api call

* integrate pickle cache file system

* Improve tile prompting cache management

* prepare next phase

* move params to refiner

* tiled prompts and tile ksampling override added

* some housekeeping

* Add McBoaty v4 and upgrade version

* add wf for McBoaty v4

---------

Co-authored-by: haohaocreates <[email protected]>
  • Loading branch information
MaraScott and haohaocreates committed Jul 1, 2024
1 parent a69f484 commit 28282c8
Show file tree
Hide file tree
Showing 21 changed files with 12,093 additions and 119 deletions.
12 changes: 9 additions & 3 deletions MaraScott_Nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#
###

from . import __SESSIONS_DIR__, __PROFILES_DIR__
from .py.nodes.Bus.AnyBus_v2 import AnyBus_v2
from .py.nodes.Info.DisplayInfoNode_v1 import DisplayInfoNode_v1
from .py.nodes.UpscalerRefiner.McBoaty_v2 import UpscalerRefiner_McBoaty_v2
from .py.nodes.UpscalerRefiner.McBoaty_v3 import UpscalerRefiner_McBoaty_v3
from .py.nodes.UpscalerRefiner.McBoaty_v4 import McBoaty_Upscaler_v4, McBoaty_TilePrompter_v4, McBoaty_Refiner_v4
from .py.nodes.KSampler.InpaintingTileByMask_v1 import KSampler_setInpaintingTileByMask_v1, KSampler_pasteInpaintingTileByMask_v1
from .py.nodes.Prompt.PromptFromImage_v1 import PromptFromImage_v1
from .py.vendor.ComfyUI_JNodes.blob.main.py.prompting_nodes import TokenCounter as TokenCounter_v1
Expand All @@ -22,7 +22,9 @@
NODE_CLASS_MAPPINGS = {
"MaraScottAnyBus_v2": AnyBus_v2,
"MaraScottDisplayInfo_v1": DisplayInfoNode_v1,
"MaraScottUpscalerRefinerNode_v3": UpscalerRefiner_McBoaty_v3,
"McBoaty_Upscaler_v4": McBoaty_Upscaler_v4,
"McBoaty_TilePrompter_v4": McBoaty_TilePrompter_v4,
"McBoaty_Refiner_v4": McBoaty_Refiner_v4,
"MaraScottSetInpaintingByMask_v1": KSampler_setInpaintingTileByMask_v1,
"MaraScottPasteInpaintingByMask_v1": KSampler_pasteInpaintingTileByMask_v1,
"MaraScottPromptFromImage_v1": PromptFromImage_v1,
Expand All @@ -32,6 +34,7 @@
"MaraScottAnyBusNode": AnyBus_v2,
"MaraScottDisplayInfoNode": DisplayInfoNode_v1,
"MaraScottUpscalerRefinerNode_v2": UpscalerRefiner_McBoaty_v2,
"MaraScottUpscalerRefinerNode_v3": UpscalerRefiner_McBoaty_v3,
}

# A dictionary that contains the friendly/humanly readable titles for the nodes
Expand All @@ -40,7 +43,9 @@
NODE_DISPLAY_NAME_MAPPINGS = {
"MaraScottAnyBus_v2": "\ud83d\udc30 AnyBus - UniversalBus v2 /*",
"MaraScottDisplayInfo_v1": "\ud83d\udc30 Display Info - Text v1 /i",
"MaraScottUpscalerRefinerNode_v3": "\ud83d\udc30 Large Refiner - McBoaty v3 /u",
"McBoaty_Upscaler_v4": "\ud83d\udc30 Upscaler - McBoaty [1/3] v4 /u",
"McBoaty_TilePrompter_v4": "\ud83d\udc30 Tile Prompter - McBoaty [2/3] v4 /u",
"McBoaty_Refiner_v4": "\ud83d\udc30 Refiner - McBoaty [3/3] v4 /u",
"MaraScottSetInpaintingByMask_v1": "\ud83d\udc30 Set Inpainting Tile by mask - McInpainty [1/2] v1 /m",
"MaraScottPasteInpaintingByMask_v1": "\ud83d\udc30 Paste Inpainting Tile by mask - McInpainty [2/2] v1 /m",
"MaraScottPromptFromImage_v1": "\ud83d\udc30 Prompt From Image - McPrompty v1 /p",
Expand All @@ -50,6 +55,7 @@
"MaraScottAnyBusNode": "\u274C AnyBus - UniversalBus v2 /*",
"MaraScottDisplayInfoNode": "\u274C Display Info - Text v1 /i",
"MaraScottUpscalerRefinerNode_v2": "\u274C Large Refiner - McBoaty v2 /u",
"MaraScottUpscalerRefinerNode_v3": "\u274C Large Refiner - McBoaty v3 /u",
}

print('\033[34m[MaraScott] \033[92mLoaded\033[0m')
84 changes: 3 additions & 81 deletions __build__.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,4 @@
#!/usr/bin/env python3

import time
# import subprocess
# import os
# from shutil import rmtree, copytree, ignore_patterns
# from glob import glob
# import re

from .py.utils.log import COLORS
from . import __ROOT__file__

start = time.time()

# ROOT_DIR = os.path.dirname(os.path.abspath(__ROOT__file__))
# SRC_WEB_DIR = os.path.abspath(f'{ROOT_DIR}/src_web/')
# WEB_DIR = os.path.abspath(f'{ROOT_DIR}/web/')
# WEB_COMFYUI_DIR = os.path.abspath(f'{WEB_DIR}/comfyui/')

# rmtree(WEB_DIR)


# def log_step(msg=None, status=None):
# """ Logs a step keeping track of timing and initial msg. """
# global step_msg # pylint: disable=W0601
# global step_start # pylint: disable=W0601
# if msg:
# step_msg = f'▻ [Starting] {msg}...'
# step_start = time.time()
# print(step_msg, end="\r")
# elif status:
# step_time = round(time.time() - step_start, 3)
# if status == 'Error':
# status_msg=f'{COLORS["RED"]}⤫ {status}{COLORS["RESET"]}'
# else:
# status_msg=f'{COLORS["BRIGHT_GREEN"]}🗸 {status}{COLORS["RESET"]}'
# print(
# f'{step_msg.ljust(50, ".")} {COLORS["BRIGHT_GREEN"]}🗸 {status}{COLORS["RESET"]} ({step_time}s)'
# )


# log_step(msg='Copying web directory')
# copytree(SRC_WEB_DIR, WEB_DIR, ignore=ignore_patterns("typings*", "*.ts", "*.scss"))
# log_step(status="Done")

# log_step(msg='TypeScript')
# checked = subprocess.run(["./node_modules/typescript/bin/tsc"], check=True)
# log_step(status="Done")

# scsss = glob(os.path.join(SRC_WEB_DIR, "**", "*.scss"), recursive=True)
# log_step(msg=f'SASS for {len(scsss)} files')
# scsss = [i.replace(ROOT_DIR, '.') for i in scsss]
# cmds = ["node", "./node_modules/sass/sass"]
# for scss in scsss:
# out = scss.replace('src_web', 'web').replace('.scss', '.css')
# cmds.append(f'{scss}:{out}')
# cmds.append('--no-source-map')
# checked = subprocess.run(cmds, check=True)
# log_step(status="Done")

# # Handle the common directories. Because ComfyUI loads under /extensions/rgthree-comfy we can't
# # easily share sources outside of the `WEB_COMFYUI_DIR` _and_ allow typescript to resolve them in
# # src view, so we set the path in the tsconfig to map an import of "rgthree/common" to the
# # "src_web/common" directory, but then need to rewrite the comfyui JS files to load from
# # "../../rgthree/common" (which we map correctly in rgthree_server.py).
# log_step(msg='Cleaning Imports')
# print('▻ [Starting] Cleaning Imports...', end="\r")
# web_subfolders = [f.name for f in os.scandir(WEB_DIR) if f.is_dir()]
# for subfolder in web_subfolders:
# js_files = glob(os.path.join(WEB_DIR, subfolder, '*.js'), recursive=True)
# for file in js_files:
# with open(file, 'r', encoding="utf-8") as f:
# filedata = f.read()
# if subfolder == 'comfyui':
# filedata = re.sub(r'(from\s+["\'])rgthree/', '\\1../../rgthree/', filedata)
# else:
# filedata = re.sub(r'(from\s+["\'])rgthree/', '\\1../', filedata)
# with open(file, 'w', encoding="utf-8") as f:
# f.write(filedata)
# log_step(status="Done")

print(f'Finished all in {round(time.time() - start, 3)}s')
# -*- coding:utf-8 -*-
#
###
11 changes: 7 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import os
import sys

from .py.utils.version import VERSION
from .py.inc.lib.llm import MS_Llm

MS_Llm.prestartup_script()
Expand All @@ -39,8 +41,6 @@
root_dir = os.path.join(base_dir, "..", "..")
web_dir = os.path.join(root_dir, "web", "extensions", "marascott")
web_dir = os.path.realpath(web_dir)
# comfy_dir = os.path.join(root_dir, "comfy")
# sys.path.insert(0, root_dir)
if not os.path.exists(web_dir):
os.makedirs(web_dir)
__WEB_DIR__ = web_dir
Expand All @@ -55,12 +55,15 @@
os.makedirs(profiles_dir)
__PROFILES_DIR__ = profiles_dir

cache_dir = os.path.join(web_dir, "cache")
if not os.path.exists(cache_dir):
os.makedirs(cache_dir)
__CACHE_DIR__ = cache_dir

from .MaraScott_Nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS, WEB_DIRECTORY

__all__ = [ 'NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY' ]

from .py.utils.version import VERSION

MANIFEST = {
"name": "MaraScott Nodes",
"version": VERSION,
Expand Down
Loading

0 comments on commit 28282c8

Please sign in to comment.