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

support fluxcontrolnet #196

Merged
merged 4 commits into from
Nov 7, 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 bizyair_extras/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .nodes_comfyui_instantid import *
from .nodes_comfyui_pulid_flux import *
from .nodes_controlnet import *
from .nodes_custom_sampler import *
from .nodes_flux import *
from .nodes_image_utils import *
from .nodes_ipadapter_plus.nodes_ipadapter_plus import *
Expand Down
32 changes: 32 additions & 0 deletions bizyair_extras/nodes_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,35 @@ def INPUT_TYPES(s):
RETURN_TYPES = (data_types.CONTROL_NET,)

# FUNCTION = "set_controlnet_type"


class ControlNetInpaintingAliMamaApply(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"positive": (data_types.CONDITIONING,),
"negative": (data_types.CONDITIONING,),
"control_net": (data_types.CONTROL_NET,),
"vae": (data_types.VAE,),
"image": ("IMAGE",),
"mask": ("MASK",),
"strength": (
"FLOAT",
{"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01},
),
"start_percent": (
"FLOAT",
{"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001},
),
"end_percent": (
"FLOAT",
{"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001},
),
}
}

# FUNCTION = "apply_inpaint_controlnet"
CATEGORY = "conditioning/controlnet"
RETURN_TYPES = (data_types.CONDITIONING, data_types.CONDITIONING)
RETURN_NAMES = ("positive", "negative")
28 changes: 28 additions & 0 deletions bizyair_extras/nodes_custom_sampler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from bizyair import BizyAirBaseNode, data_types


class CFGGuider(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"model": (data_types.MODEL,),
"positive": (data_types.CONDITIONING,),
"negative": (data_types.CONDITIONING,),
"cfg": (
"FLOAT",
{
"default": 8.0,
"min": 0.0,
"max": 100.0,
"step": 0.1,
"round": 0.01,
},
),
}
}

RETURN_TYPES = ("GUIDER",)

# FUNCTION = "get_guider"
CATEGORY = "sampling/custom_sampling/guiders"
32 changes: 32 additions & 0 deletions bizyair_extras/nodes_sd3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,35 @@ def INPUT_TYPES(s):
# FUNCTION = "load_clip"

CATEGORY = "advanced/loaders"


class ControlNetApplySD3(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"positive": (data_types.CONDITIONING,),
"negative": (data_types.CONDITIONING,),
"control_net": (data_types.CONTROL_NET,),
"vae": (data_types.VAE,),
"image": ("IMAGE",),
"strength": (
"FLOAT",
{"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01},
),
"start_percent": (
"FLOAT",
{"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001},
),
"end_percent": (
"FLOAT",
{"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001},
),
}
}

CATEGORY = "conditioning/controlnet"
# DEPRECATED = True
NODE_DISPLAY_NAME = "Apply Controlnet with VAE"
RETURN_TYPES = (data_types.CONDITIONING, data_types.CONDITIONING)
RETURN_NAMES = ("positive", "negative")
1 change: 1 addition & 0 deletions src/bizy_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

TYPE_OPTIONS = {
"lora": "bizyair/lora",
"controlnet": "bizyair/controlnet",
# "other": "other",
}
ALLOW_TYPES = list(TYPE_OPTIONS.values())
Expand Down
2 changes: 1 addition & 1 deletion src/bizyair/common/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def process_response_data(response_data: dict) -> dict:
try:
msg = json.loads(response_data["result"])
except json.JSONDecodeError:
raise ValueError("Failed to decode JSON from response.")
raise ValueError(f"Failed to decode JSON from response. {response_data=}")
else:
# Handle local response directly
msg = response_data
Expand Down
5 changes: 4 additions & 1 deletion src/bizyair/configs/models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ model_hub:

model_types:
loras: bizyair/lora
controlnet: bizyair/controlnet
# folder_name, server_folder_name
# checkpoints: bizyair/checkpoint
# vae: bizyair/vae
Expand All @@ -18,6 +19,8 @@ routing_configs:
route: /supernode/flux-dev-bizyair-comfy-ksampler-speedup
flux-schnell:
route: /supernode/flux-bizyair-sdxl-comfy-ksampler
flux-vae:
route: /supernode/flux-vae-bizyair-comfy-ksampler
ultimatesdupscale:
route: /supernode/bizyair-ultimate-sd-upscale-ksampler
sd3_5_large:
Expand Down Expand Up @@ -45,7 +48,7 @@ routing_rules:
config: flux-schnell
- name: flux-vae
pattern: ^flux/ae.sft$
config: flux-schnell
config: flux-vae
- name: sd3_5_large
pattern: ^sd3.5_large.safetensors$
config: sd3_5_large
Expand Down
31 changes: 19 additions & 12 deletions src/bizyair/path_utils/path_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def guess_url_from_node(
+ "/supernode/bizyair-flux-dev-comfy-pulid"
)

if class_type_table.get("LoraLoader", False):
if class_type_table.get(
"LoraLoader", False
) or class_type_table.get("ControlNetLoader", False):
node["inputs"][
"weight_dtype"
] = "fp8_e4m3fn" # set to fp8_e4m3fn for lora
Expand Down Expand Up @@ -174,17 +176,22 @@ def convert_prompt_label_path_to_real_path(prompt: dict[str, dict[str, any]]) ->
for unique_id in prompt:
new_prompt[unique_id] = copy.copy(prompt[unique_id])
inputs = copy.copy(prompt[unique_id]["inputs"])
if "lora_name" in inputs:
lora_name = inputs["lora_name"]
new_lora_name = filename_path_mapping.get("loras", {}).get(lora_name, None)
if new_lora_name:
inputs["lora_name"] = new_lora_name
else:
file_list = get_filename_list("loras")
if lora_name not in file_list:
raise ValueError(
f"Lora name '{lora_name}' not found in file list. Available lora names: {', '.join(file_list)}"
)

for key, folder_name in [
("lora_name", "loras"),
("control_net_name", "controlnet"),
]:
if key in inputs:
value = inputs[key]
new_value = filename_path_mapping.get(folder_name, {}).get(value, None)
if new_value:
inputs[key] = new_value
else:
file_list = get_filename_list(folder_name)
if value not in file_list:
raise ValueError(
f"{key} '{value}' not found in file list. Available {key} names: {', '.join(file_list)}"
)

new_prompt[unique_id]["inputs"] = inputs
return new_prompt
Expand Down
Loading