added LM Studio Prompt node

This commit is contained in:
bash-j
2023-12-21 13:23:04 +10:30
parent 84c3c64b29
commit 5fc7ed5dab
+314 -11
View File
@@ -38,7 +38,7 @@ sys.modules[module_name] = module
spec.loader.exec_module(module)
from nodes_upscale_model import UpscaleModelLoader, ImageUpscaleWithModel
from comfy.model_management import soft_empty_cache, free_memory, get_torch_device, current_loaded_models, load_model_gpu
from nodes import LoraLoader, ConditioningAverage, common_ksampler, ImageScale, VAEEncode, VAEDecode
from nodes import LoraLoader, ConditioningAverage, common_ksampler, ImageScale, ImageScaleBy, VAEEncode, VAEDecode
import comfy.utils
from comfy_extras.chainner_models import model_loading
from comfy import model_management, model_base
@@ -536,6 +536,17 @@ def tensor2numpy(image):
# Convert tensor to numpy array and transpose dimensions from (C, H, W) to (H, W, C)
return (255.0 * image.cpu().numpy().squeeze().transpose(1, 2, 0)).astype(np.uint8)
# create a wrapper function that can apply a function to multiple images in a batch
# while passing all other arguments to the function
def apply_to_batch(func):
def wrapper(self, image, *args, **kwargs):
images = []
for img in image:
images.append(func(self, img, *args, **kwargs))
batch_tensor = torch.cat(images, dim=0)
return (batch_tensor, )
return wrapper
class WildcardProcessor:
@classmethod
def INPUT_TYPES(s):
@@ -571,6 +582,7 @@ class HaldCLUT:
CATEGORY = 'Mikey/Image'
OUTPUT_NODE = True
@apply_to_batch
def apply_haldclut(self, image, hald_clut, gamma_correction):
hald_img = Image.open(self.haldclut_files[self.file_names.index(hald_clut)])
img = tensor2pil(image)
@@ -579,7 +591,8 @@ class HaldCLUT:
else:
corrected_img = img
filtered_image = apply_hald_clut(hald_img, corrected_img).convert("RGB")
return (pil2tensor(filtered_image), )
#return (pil2tensor(filtered_image), )
return pil2tensor(filtered_image)
@classmethod
def IS_CHANGED(self, hald_clut):
@@ -807,7 +820,8 @@ class PresetRatioSelector:
if use_preset_seed == 'true' and len(self.ratio_presets) > 0:
# seed is a randomly generated number that can be much larger than the number of presets
# we use the seed to select a preset
offset = seed % len(self.ratio_presets - 1)
len_presets = len(self.ratio_presets)
offset = seed % (len_presets - 1)
presets = [p for p in self.ratio_presets if p != 'none']
select_preset = presets[offset]
latent_width = self.ratio_config[select_preset]['custom_latent_w']
@@ -2471,10 +2485,12 @@ class MikeySamplerBaseOnly:
class MikeySamplerBaseOnlyAdvanced:
@classmethod
def INPUT_TYPES(s):
s.image_scaler = ImageScaleBy()
s.upscale_models = folder_paths.get_filename_list("upscale_models")
s.all_upscale_models = s.upscale_models + s.image_scaler.upscale_methods
try:
default_model = '4x-UltraSharp.pth' if '4x-UltraSharp.pth' in s.upscale_models else s.upscale_models[0]
um = (s.upscale_models, {'default': default_model})
default_model = 'lanczos' #'4x-UltraSharp.pth' if '4x-UltraSharp.pth' in s.upscale_models else s.upscale_models[0]
um = (s.all_upscale_models, {'default': default_model})
except:
um = (folder_paths.get_filename_list("upscale_models"), )
return {"required": {"base_model": ("MODEL",),
@@ -2508,7 +2524,10 @@ class MikeySamplerBaseOnlyAdvanced:
vaeencoder = VAEEncode()
vaedecoder = VAEDecode()
uml = UpscaleModelLoader()
upscale_model = uml.load_model(upscale_model)[0]
if upscale_model in image_scaler.upscale_methods:
upscale_model = upscale_model
else:
upscale_model = uml.load_model(upscale_model)[0]
iuwm = ImageUpscaleWithModel()
# step 1 run base model low cfg
start_step = int(steps - (steps * denoise))
@@ -2536,7 +2555,10 @@ class MikeySamplerBaseOnlyAdvanced:
# step 3 upscale
pixels = vaedecoder.decode(vae, sample2)[0]
org_width, org_height = pixels.shape[2], pixels.shape[1]
img = iuwm.upscale(upscale_model, image=pixels)[0]
if isinstance(upscale_model, str):
img = self.image_scaler.upscale(pixels, upscale_model, upscale_by)[0]
else:
img = iuwm.upscale(upscale_model, image=pixels)[0]
upscaled_width, upscaled_height = int(org_width * upscale_by // 8 * 8), int(org_height * upscale_by // 8 * 8)
img = image_scaler.upscale(img, 'nearest-exact', upscaled_width, upscaled_height, 'center')[0]
if hires_denoise == 0:
@@ -3197,6 +3219,7 @@ class ImageCaption:
wrapped_lines.append(new_line)
return wrapped_lines
@apply_to_batch
def caption(self, image, font, caption, extra_pnginfo=None, prompt=None):
if extra_pnginfo is None:
extra_pnginfo = {}
@@ -3249,7 +3272,8 @@ class ImageCaption:
combined_image.paste(text_image, (0, height))
combined_image.paste(orig_image, (0, 0))
return (pil2tensor(combined_image),)
#return (pil2tensor(combined_image),)
return pil2tensor(combined_image)
def tensor2pil_alpha(tensor):
# convert a PyTorch tensor to a PIL Image object
@@ -3308,6 +3332,7 @@ class ImageBorder:
border_image.paste(image, (border_width, border_width))
return pil2tensor(border_image)[None, :, :, :]
@apply_to_batch
def border(self, image, border_width, border_color):
# Convert tensor to PIL image
orig_image = tensor2pil(image)
@@ -3324,7 +3349,8 @@ class ImageBorder:
border_image = Image.new('RGB', (width + border_width * 2, height + border_width * 2), border_color)
border_image.paste(orig_image, (border_width, border_width))
return (pil2tensor(border_image),)
#return (pil2tensor(border_image),)
return pil2tensor(border_image)
class ImagePaste:
# takes 2 images, background image and foreground image with transparency areas
@@ -3564,7 +3590,7 @@ class OobaPrompt:
@classmethod
def INPUT_TYPES(s):
return {'required': {'input_prompt': ('STRING', {'multiline': True, 'default': 'Prompt Text Here', 'dynamicPrompts': False}),
'mode': (['prompt', 'style', 'descriptor', 'character', 'custom'], {'default': 'prompt'}),
'mode': (['prompt', 'style', 'descriptor', 'character', 'negative', 'custom'], {'default': 'prompt'}),
'custom_history': ('STRING', {'multiline': False, 'default': 'path to history.json', 'dynamicPrompts': True}),
'seed': ('INT', {'default': 0, 'min': 0, 'max': 0xffffffffffffffff}),},
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO", "prompt": "PROMPT"}}
@@ -3804,6 +3830,55 @@ class OobaPrompt:
]
]
}
elif mode == 'negative':
return {
"internal": [
[
"<|BEGIN-VISIBLE-CHAT|>",
"How can I help you today?"
],
[
"I provide a prompt for a text to image AI model, and you will respond with a prompt that helps to improve the quality of the image." \
"The prompt contains styles you don't want to see in the image. For example if the user asks for a photo, the your response would contain terms such as 'cartoon, illustration, 3d render'."\
"The word 'no' is forbidden!. Do not repeat yourself, do not provide similar but different words. Do not provide sentences, just words separated by commas. Keep it short.",
"Sure thing! Let's begin. What is your first prompt?"
],
[
"breathtaking image of a woman in a red dress. award-winning, professional, highly detailed",
"ugly, deformed, noisy, blurry, distorted, grainy, plain background, monochrome, signature, watermark."
],
[
"concept art. digital artwork, illustrative, painterly, matte painting, highly detailed",
"photo, photorealistic, realism, ugly, signature."
],
[
"3d model, unreal engine, textures, volumetric lighting, raytraced rendering, subject centered",
"watermark, 2D, low poly, polygon mesh, cartoon, trypophobia, miniature, traditional art, logo."
],
[
"comic book art, onomatopoeic graphics, halftone dots, color separation, bold lines, reminiscent of art from Marvel, DC, Dark Horse, Image, and other comic book publishers",
"photo, photorealistic, realism, ugly, signature."
],
[
"dark fantasy art, gothic themes, macabre, horror, dark, gloomy, sinister, ominous, eerie",
"watermark, bright colors, cheerful, happy, cute, cartoon, anime, digital art, 3d render, photograph, 2d art."
],
[
"charcoal drawing, rich blacks, contrasting whites, smudging, erasure, hatching, cross-hatching, tonal values, rough texture",
"photograph, painting, watercolor, colorful, 3d render, cartoon, anime, digital art."
],
[
"stunning photograph of a tiger in a tropical rainforest",
"black and white, cartoon, illustration, low resolution, noisy, blurry, desaturated, ugly, deformed."
]
],
"visible": [
[
"",
"How can I help you today?"
]
]
}
elif mode == 'custom':
# open json file that is in the custom_history path
try:
@@ -3923,6 +3998,223 @@ class WildcardOobaPrompt:
prompt.get(str(unique_id))['inputs']['output_text'] = input_prompt
return (input_prompt,)
# same function as oobaprompt but using the LM Studio API
class LMStudioPrompt:
@classmethod
def INPUT_TYPES(s):
return {'required': {'input_prompt': ('STRING', {'multiline': True, 'default': 'Prompt Text Here', 'dynamicPrompts': False}),
'mode': (['prompt', 'style', 'descriptor', 'character', 'custom'], {'default': 'prompt'}),
'custom_history': ('STRING', {'multiline': False, 'default': 'path to history.json', 'dynamicPrompts': True}),
'server_address': ('STRING', {'default': 'localhost'}),
'server_port': ('INT', {'default': 1234, 'min': 0, 'max': 65535}),
'seed': ('INT', {'default': 0, 'min': 0, 'max': 0xffffffffffffffff}),},
"hidden": {"unique_id": "UNIQUE_ID", "extra_pnginfo": "EXTRA_PNGINFO", "prompt": "PROMPT"}}
RETURN_TYPES = ('STRING',)
RETURN_NAMES = ('text',)
FUNCTION = 'process'
OUTPUT_NODE = True
CATEGORY = 'Mikey/AI'
def history(self, mode, custom_history):
if mode == 'prompt':
return {
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "I say something like 'blonde woman' and you respond with a single prompt which I can use as prompts for an AI txt2image model. Your response to blonde woman would be something like 'Blonde woman wearing a patterned orange, white, and blue sundress, smiling, on a sunny day with a blue sky, surrounded by buildings and palm trees'. It describes the image with lots of details so the AI model will understand what it needs to generate."},
{ "role": "assistant", "content": "Sure thing! Let's begin. What is your first prompt?" },
{ "role": "user", "content": "futuristic man"},
{ "role": "assistant", "content": "Man with short black hair in a highly detailed silver and black mechanical exoskeleton suit, holding a futuristic rifle, standing in a futuristic city with tall buildings and flying cars, with a futuristic cityscape in the background."},
{ "role": "user", "content": "a black cat"},
{ "role": "assistant", "content": "A black cat with green eyes, sitting on a wooden table, there is a vase of flowers on the table, the cat is looking at the flowers. Sunlight is streaming in through a window, illuminating the cat and the flowers."},
{ "role": "user", "content": "toaster oven"},
{ "role": "assistant", "content": "A toaster oven with a slice of bread inside, the bread is toasted and has a smiley face burned into it. The toaster oven is sitting on a kitchen counter next to a coffee maker and a microwave. The kitchen counter is made of granite and has a sink in it. There is a window above the sink with a view of a city skyline."},
{ "role": "user", "content": "war"},
{ "role": "assistant", "content": "A soldier wearing a gas mask and a helmet, holding a rifle, standing in a trench. There is barbed wire in front of the trench. The sky is dark and cloudy. There is a tank in the background."},
{ "role": "user", "content": "portrait of a man"},
{ "role": "assistant", "content": "A portrait of a man in his 30s with short brown hair and a beard. He is wearing a suit and tie. He is smiling. He is standing in front of a brick wall with graffiti on it."},
{ "role": "user", "content": "a friendly ogre"},
{ "role": "assistant", "content": "A friendly ogre with green skin and a big smile. He is wearing a red and white striped shirt and blue overalls. He is holding a pitchfork. He is standing in a field of flowers. There is a rainbow in the sky."},
{ "role": "user", "content": "puppy"},
{ "role": "assistant", "content": "A cute pug dog wearing a bowtie and reading a book. The book is titled 'How to be a good dog'. The dog is sitting on a couch in a living room. There is a fireplace in the background."},
{ "role": "user", "content": "apples"},
{ "role": "assistant", "content": "Red apples stacked in a wooden crate. The crate is sitting on a wooden table in the kitchen inside a rustic farm house with old appliances. The walls are decorated with family photos. There is a window in the background with a view of the farm."},
{ "role": "user", "content": "working woman"},
{ "role": "assistant", "content": "A woman is working on a laptop computer. She is wearing a white shirt and black pants. She is sitting at a desk in a modern office with trendy furniture. She has a cup of coffee on the desk next to her."}
]
}
elif mode == 'style':
return {
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "I say something like 'painting' and you respond with a single prompt which I can use as prompts for an AI txt2image model. Your response to painting would be something like 'Impressionistic, landscape, vivid colors, loose brushstrokes, beauty of nature. Inspired by Claude Monet'. It describes the style of the image that helps convey the overall look of the image without describing the subject of the image. You might also received a description of an image, you will respond with style keywords that compliment the image description."},
{ "role": "assistant", "content": "Sure thing! Let's begin. What is your first prompt?" },
{ "role": "user", "content": "painting"},
{ "role": "assistant", "content": "Realism, oil painting, dark shadows, bright highlights, focus on capturing light and texture. Inspired by Caravaggio's chiaroscuro technique"},
{ "role": "user", "content": "Impressionism"},
{ "role": "assistant", "content": "Impressionism. Soft brushstrokes, fleeting moments of light and color. Landscapes, flowers, people in motion"},
{ "role": "user", "content": "painting"},
{ "role": "assistant", "content": "Impressionistic, landscape, vivid colors, loose brushstrokes, beauty of nature. Inspired by Claude Monet"},
{ "role": "user", "content": "The 2015 Audi R8 Spyder sports car is parked on a driveway outside a luxurious mansion. The car is painted in a metallic grey color. The top is down revealing the sleek interior. The car is surrounded by lush greenery and palm trees."},
{ "role": "assistant", "content": "Landscape photography, vibrant saturation, dramatic shadows, golden hour lighting, inspired by the work of Peter Lik."},
{ "role": "user", "content": "abstract"},
{ "role": "assistant", "content": "Abstract expressionism, bold brushstrokes, vivid colors"},
{ "role": "user", "content": "water"},
{ "role": "assistant", "content": "Water sculpture, fluid dynamics, abstract representation, in the style of Yves Klein"},
{ "role": "user", "content": "A MacBook Pro open and displaying an email message. The keyboard is illuminated and the trackpad is being used. A man is sitting at a wooden desk in a cozy home office. There is a plant in the corner and sunlight coming in from a nearby window."},
{ "role": "assistant", "content": "Still life, muted colors, soft lighting, in the style of Henri Matisse"},
{ "role": "user", "content": "Surrealism"},
{ "role": "assistant", "content": "dreamlike imagery, unexpected juxtapositions, symbolic elements. features distorted or unusual forms, animals or objects transformed into otherworldly shapes"},
{ "role": "user", "content": "Art Nouveau"},
{ "role": "assistant", "content": "Art Nouveau style, flowing lines, organic shapes, muted color palette, decorative elements, floral motifs."},
{ "role": "user", "content": "photo"},
{ "role": "assistant", "content": "Black and white photograph, shot using a large format camera with slow shutter speeds. Grainy texture and high contrast. Influenced by the works of Edward Hopper."},
{ "role": "user", "content": "photo"},
{ "role": "assistant", "content": "Color photograph, Soft focus, muted colors, romantic atmosphere, in the style of Edward Weston."},
{ "role": "user", "content": "film"},
{ "role": "assistant", "content": "Long shot, film still, cinematic lighting, gritty realism, inspired by the works of Gus Van Sant"},
{ "role": "user", "content": "movie"},
{ "role": "assistant", "content": "Filmic storytelling, dreamlike imagery, surreal elements, poetic narratives, reminiscent of the works of David Lynch."}
]
}
elif mode == 'descriptor':
return {
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "I say something like 'color' and you respond with a single prompt which I can use to build a prompt for an AI txt2image model. Your response to color would be something like 'red'. It is a very short description to add dynamic variety to the prompt."},
{ "role": "assistant", "content": "Sure thing! Let's begin. What is your first prompt?" },
{ "role": "user", "content": "color"},
{ "role": "assistant", "content": "burnt sienna"},
{ "role": "user", "content": "hair color"},
{ "role": "assistant", "content": "platinum blonde"},
{ "role": "user", "content": "metal"},
{ "role": "assistant", "content": "rusted iron"},
{ "role": "user", "content": "weather"},
{ "role": "assistant", "content": "bright and sunny"},
{ "role": "user", "content": "time of day"},
{ "role": "assistant", "content": "crack of dawn"},
{ "role": "user", "content": "man"},
{ "role": "assistant", "content": "tall and slender man with wide shoulders in his 30s"},
{ "role": "user", "content": "ethnicity"},
{ "role": "assistant", "content": "Vietnamese"},
{ "role": "user", "content": "occupation"},
{ "role": "assistant", "content": "Heavy diesel mechanic"},
{ "role": "user", "content": "art style"},
{ "role": "assistant", "content": "crystal cubism"},
{ "role": "user", "content": "artist"},
{ "role": "assistant", "content": "Camille Pissarro"},
{ "role": "user", "content": "movie director"},
{ "role": "assistant", "content": "David Lynch"}
]
}
elif mode == 'character':
return {
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "When a user requests a character description, generate a detailed description of the character as you would expect from the writer George R. R. Martin. The description should be a suitable prompt based on the description that encapsulates the character's key visual elements for image creation using a txt2img model."},
{ "role": "assistant", "content": "Sure thing! Let's begin. What is your first prompt?" },
{ "role": "user", "content": "jolly cartoon octopus"},
{ "role": "assistant", "content": "A cartoon octopus with a jolly demeanor in a sunshiny yellow and orange color scheme, wearing a small top hat and a polka-dotted bow tie, surrounded by intricate sculptures made of its own ink, in the midst of an undersea setting that hints at festivity and mirth."},
{ "role": "user", "content": "a dapper young lady spy who wears suits"},
{ "role": "assistant", "content": "A young 1920s lady spy with chestnut hair in a bob cut, piercing emerald eyes, wearing a tailored charcoal pinstripe suit with a white shirt and a silk tie, holding a silver cigarette case, exuding an aura of mystery and sophistication against a backdrop of Parisian nightlife."},
{ "role": "user", "content": "a charming robot"},
{ "role": "assistant", "content": "A charming robot with a sleek chrome body, art deco design elements, azure glowing eyes, and a gentle smile. Wearing a holographic bow tie and a vest painted to look like a dapper suit, engaged in performing a magic trick with a playful, inquisitive expression in an urban park setting."},
{ "role": "user", "content": "cartoon ant"},
{ "role": "assistant", "content": "A cartoon ant with a vibrant blue exoskeleton, oversized round eyes full of curiosity, wearing a leaf-green vest and a tiny fabric cap. Exhibiting an expression of wonder and excitement, amidst a backdrop of an underground ant colony bustling with activity."},
{ "role": "user", "content": "a cyberpunk gnome"},
{ "role": "assistant", "content": "A cyberpunk gnome with pale skin and cybernetic jade eyes, wearing a long tattered coat with circuitry patches and a sleek metallic pointed helmet. Surrounded by holographic screens and neon lights in a dim, cluttered workshop filled with futuristic gadgets and data screens."}
]
}
elif mode == 'custom':
# open json file that is in the custom_history path
try:
history = json.load(open(custom_history))
return history
except:
raise Exception('Error loading custom history file')
def api_request(self, prompt, server_address, server_port, seed, mode, custom_history):
# check if json file in root comfy directory called oooba.json
history = self.history(mode, custom_history)
if mode == 'prompt':
prompt = f'{prompt}, describe in detail.'
if mode == 'descriptor':
# use seed to add a bit more randomness to the prompt
spice = ['a', 'the', 'this', 'that',
'an exotic', 'an interesting', 'a colorful', 'a vibrant', 'get creative!', 'think outside the box!', 'a rare',
'a standard', 'a typical', 'a common', 'a normal', 'a regular', 'a usual', 'an ordinary',
'a unique', 'a one of a kind', 'a special', 'a distinctive', 'a peculiar', 'a remarkable', 'a noteworthy',
'popular in the victorian era', 'popular in the 1920s', 'popular in the 1950s', 'popular in the 1980s',
'popular in the 1990s', 'popular in the 2000s', 'popular in the 2010s', 'popular in the 2020s',
'popular in asia', 'popular in europe', 'popular in north america', 'popular in south america',
'popular in africa', 'popular in australia', 'popular in the middle east', 'popular in the pacific islands',
'popular with young people', 'popular with the elderly', 'trending on social media', 'popular on tiktok',
'trending on pinterest', 'popular on instagram', 'popular on facebook', 'popular on twitter',
'popular on reddit', 'popular on youtube', 'popular on tumblr', 'popular on snapchat',
'popular on linkedin', 'popular on twitch', 'popular on discord',
'unusual example of', 'a classic', 'an underrated', 'an innovative','a historical', 'a modern', 'a contemporary',
'a futuristic', 'a traditional', 'an eco-friendly', 'a controversial', 'a political', 'a religious',
'a spiritual', 'a philosophical', 'a scientific']
random.seed(seed)
prompt = f'{random.choice(spice)} {prompt}'
"""
example curl request to LM Studio
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "system", "content": "Always answer in rhymes." },
{ "role": "user", "content": "Introduce yourself." }
],
"temperature": 0.7,
"max_tokens": -1,
"stream": false
}'
"""
#prompt_prefix = "\\n<|user|>\\n"
#prompt_suffix = "\\n<|assistant|>\\n"
#prompt = prompt_prefix + prompt + prompt_suffix
history['messages'].append({'role': 'user', 'content': prompt})
request = {
'messages': history['messages'],
'temperature': 0.2,
'top_p': 0.95,
'presence_penalty': 0.0,
'frequency_penalty': 0.0,
'max_tokens': 1200,
'stream': False,
'seed': seed,
}
HOST = f'{server_address}:{server_port}'
URI = f'http://{HOST}/v1/chat/completions'
try:
response = requests.post(URI, json=request, timeout=60)
except requests.exceptions.ConnectionError:
raise Exception('Are you running LM Studio with server running?')
if response.status_code == 200:
# response is in openai format
result = response.json()['choices'][0]['message']['content']
result = html.unescape(result) # decode URL encoded special characters
return result
else:
return 'Error'
def process(self, input_prompt, mode, custom_history, server_address, server_port, seed, prompt=None, unique_id=None, extra_pnginfo=None):
# search and replace
input_prompt = search_and_replace(input_prompt, extra_pnginfo, prompt)
# wildcard sytax is {like|this}
# select a random word from the | separated list
wc_re = re.compile(r'{([^}]+)}')
def repl(m):
return random.choice(m.group(1).split('|'))
for m in wc_re.finditer(input_prompt):
input_prompt = input_prompt.replace(m.group(0), repl(m))
result = self.api_request(input_prompt, server_address, server_port, seed, mode, custom_history)
prompt.get(str(unique_id))['inputs']['output_text'] = result
return (result,)
class EvalFloats:
# takes two float inputs and a text widget the user can type a formula for values a and b to calculate
# then returns the result as the output
@@ -4012,6 +4304,7 @@ class CinematicLook:
filtered_image = apply_hald_clut(hald_img, corrected_img).convert("RGB")
return filtered_image
@apply_to_batch
def cinematic_look(self, image, look):
# load haldclut
if look == 'modern':
@@ -4048,7 +4341,15 @@ class CinematicLook:
image = IO.overlay(image, noise, 0.25)[0]
if look == 'black and white - warm':
image = IO.overlay(image, noise, 0.25)[0]
return (image,)
return image
#def apply_cinematic_look(self, image, look):
# # image can be 1 or more images if batch size > 1
# images = []
# for img in image:
# images.append(self.cinematic_look(img, look))
# batch_tensor = torch.cat(images, dim=0)
# return (batch_tensor, )
NODE_CLASS_MAPPINGS = {
'Wildcard Processor': WildcardProcessor,
@@ -4101,6 +4402,7 @@ NODE_CLASS_MAPPINGS = {
'TextPreserve': TextPreserve,
'OobaPrompt': OobaPrompt,
'WildcardOobaPrompt': WildcardOobaPrompt,
'LMStudioPrompt': LMStudioPrompt,
'EvalFloats': EvalFloats,
'ImageOverlay': ImageOverlay,
'CinematicLook': CinematicLook
@@ -4157,6 +4459,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
'TextPreserve': 'Text Preserve (Mikey)',
'OobaPrompt': 'OobaPrompt (Mikey)',
'WildcardOobaPrompt': 'Wildcard OobaPrompt (Mikey)',
'LMStudioPrompt': 'LM Studio Prompt (Mikey)',
'EvalFloats': 'Eval Floats (Mikey)',
'ImageOverlay': 'Image Overlay (Mikey)',
'CinematicLook': 'Cinematic Look (Mikey)'