Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sdxl instantid #117

Merged
merged 12 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# BizyAir

- [2024/09/06] 🌩️ BizyAir supports InstantID for SDXL now. [SDXL InstantID workflow](./examples/bizyair_sdxl_InstantID_basic.json)
- [2024/09/05] 🌩️ BizyAir supports users in running custom LoRA models, including SDXL and Flux LoRA. [How to upload and run custom model](https://siliconflow.github.io/BizyAir/model-host/introduce.html)
- [2024/08/23] 🌩️ BizyAir now support ultimateSDupscale nodes [upscale workflow](./examples/bizyair_ultimate_sd_upscale.json)
- [2024/08/14] 🌩️ BizyAir JoyCaption node has been released. [Try the example to recreate a image by JoyCaption and Flux](./examples/bizyair_flux_joycaption_img2img_workflow.json), thanks to [fancyfeast/joy-caption-pre-alpha](https://huggingface.co/spaces/fancyfeast/joy-caption-pre-alpha)
Expand Down
3 changes: 2 additions & 1 deletion bizyair_example_menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Image to Image by BizyAir KSampler": "bizyair_showcase_ksampler_img2img.json",
"LoRA workflow by BizyAir KSampler": "bizyair_showcase_ksampler_lora.json",
"ControlNet workflow by BizyAir KSampler": "bizyair_showcase_ksampler_controlnet.json",
"IP Adapter workflow by BizyAir KSampler": "bizyair_showcase_ksampler_ipadapter.json"
"IP Adapter workflow by BizyAir KSampler": "bizyair_showcase_ksampler_ipadapter.json",
"InstantID Basic workflow by BizyAir KSampler": "bizyair_sdxl_InstantID_basic.json"
},
"Kolors": {
"Kolors Text to Image": "bizyair_kolors_txt2img.json",
Expand Down
3 changes: 3 additions & 0 deletions bizyair_extras/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .nodes_comfyui_instantid import *
from .nodes_controlnet import *
from .nodes_image_utils import *
from .nodes_ipadapter_plus.nodes_ipadapter_plus import *
from .nodes_kolors_mz import *
from .nodes_testing_utils import *
Expand Down
164 changes: 164 additions & 0 deletions bizyair_extras/nodes_comfyui_instantid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
from bizyair import BizyAirBaseNode, data_types
from bizyair.path_utils import path_manager as folder_paths


class InstantIDModelLoader(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"instantid_file": (folder_paths.get_filename_list("instantid"),)
}
}

RETURN_TYPES = (data_types.INSTANTID,)
FUNCTION = "default_function"
CATEGORY = "InstantID"
NODE_DISPLAY_NAME = "Load InstantID Model"


class ApplyInstantID(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"instantid": (data_types.INSTANTID,),
"insightface": (data_types.FACEANALYSIS,),
"control_net": (data_types.CONTROL_NET,),
"image": ("IMAGE",),
"model": (data_types.MODEL,),
"positive": (data_types.CONDITIONING,),
"negative": (data_types.CONDITIONING,),
"weight": (
"FLOAT",
{
"default": 0.8,
"min": 0.0,
"max": 5.0,
"step": 0.01,
},
),
"start_at": (
"FLOAT",
{
"default": 0.0,
"min": 0.0,
"max": 1.0,
"step": 0.001,
},
),
"end_at": (
"FLOAT",
{
"default": 1.0,
"min": 0.0,
"max": 1.0,
"step": 0.001,
},
),
},
"optional": {
"image_kps": ("IMAGE",),
"mask": ("MASK",),
},
}

RETURN_TYPES = (
data_types.MODEL,
data_types.CONDITIONING,
data_types.CONDITIONING,
)
RETURN_NAMES = (
"MODEL",
"positive",
"negative",
)
# FUNCTION = "apply_instantid" use default_function
CATEGORY = "InstantID"
NODE_DISPLAY_NAME = "Apply InstantID"


class ApplyInstantIDAdvanced(ApplyInstantID):
NODE_DISPLAY_NAME = "Apply InstantID Adavanced"

@classmethod
def INPUT_TYPES(s):
return {
"required": {
"instantid": (data_types.INSTANTID,),
"insightface": (data_types.FACEANALYSIS,),
"control_net": (data_types.CONTROL_NET,),
"image": ("IMAGE",),
"model": (data_types.MODEL,),
"positive": (data_types.CONDITIONING,),
"negative": (data_types.CONDITIONING,),
"ip_weight": (
"FLOAT",
{
"default": 0.8,
"min": 0.0,
"max": 3.0,
"step": 0.01,
},
),
"cn_strength": (
"FLOAT",
{
"default": 0.8,
"min": 0.0,
"max": 10.0,
"step": 0.01,
},
),
"start_at": (
"FLOAT",
{
"default": 0.0,
"min": 0.0,
"max": 1.0,
"step": 0.001,
},
),
"end_at": (
"FLOAT",
{
"default": 1.0,
"min": 0.0,
"max": 1.0,
"step": 0.001,
},
),
"noise": (
"FLOAT",
{
"default": 0.0,
"min": 0.0,
"max": 1.0,
"step": 0.1,
},
),
"combine_embeds": (
["average", "norm average", "concat"],
{"default": "average"},
),
},
"optional": {
"image_kps": ("IMAGE",),
"mask": ("MASK",),
},
}


class InstantIDFaceAnalysis(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"provider": (["CUDA"],),
},
}

RETURN_TYPES = (data_types.FACEANALYSIS,)
# FUNCTION = "load_insight_face"
CATEGORY = "InstantID"
NODE_DISPLAY_NAME = "InstantID Face Analysis"
19 changes: 19 additions & 0 deletions bizyair_extras/nodes_controlnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from comfy.cldm.control_types import UNION_CONTROLNET_TYPES

from bizyair import BizyAirBaseNode, data_types


class SetUnionControlNetType(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"control_net": (data_types.CONTROL_NET,),
"type": (["auto"] + list(UNION_CONTROLNET_TYPES.keys()),),
}
}

CATEGORY = "conditioning/controlnet"
RETURN_TYPES = (data_types.CONTROL_NET,)

# FUNCTION = "set_controlnet_type"
68 changes: 68 additions & 0 deletions bizyair_extras/nodes_image_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import os
import urllib.request

import folder_paths

from bizyair import BizyAirBaseNode
from bizyair.image_utils import encode_data
from nodes import LoadImage


class LoadImageURL(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"url": (
"STRING",
{
"multiline": True, # True if you want the field to look like the one on the ClipTextEncode node
"default": "url or path",
"lazy": True,
},
),
},
}

CATEGORY = "image_utils"
RETURN_TYPES = ("IMAGE", "MASK")
FUNCTION = "apply"
NODE_DISPLAY_NAME = "Load Image (URL)"

def apply(self, url: str):
url = url.strip()
input_dir = folder_paths.get_input_directory()
filename = os.path.basename(url)
file_path = os.path.join(input_dir, filename)

# Check if the file already exists
if os.path.exists(file_path):
print(f"File {filename} already exists, skipping download.")
else:
# Download the image
urllib.request.urlretrieve(url, file_path)
print(f"Image successfully downloaded and saved as {filename}.")
return LoadImage().load_image(filename)


class Image_Encode(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {"image": ("IMAGE",)},
"optional": {
"lossless": (
"BOOLEAN",
{"default": False, "label_on": "yes", "label_off": "no"},
),
},
}

CATEGORY = "image_utils"
FUNCTION = "apply"
RETURN_TYPES = ("IMAGE",)
NODE_DISPLAY_NAME = "Image Encode"

def apply(self, image, lossless=False):
out = encode_data(image, lossless=lossless)
return (out,)
Loading
Loading