mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-07-12 02:17:26 +08:00
Merge branch 'comfyanonymous:master' into chroma-support
This commit is contained in:
commit
7012015928
@ -9,8 +9,14 @@ class AppSettings():
|
|||||||
self.user_manager = user_manager
|
self.user_manager = user_manager
|
||||||
|
|
||||||
def get_settings(self, request):
|
def get_settings(self, request):
|
||||||
file = self.user_manager.get_request_user_filepath(
|
try:
|
||||||
request, "comfy.settings.json")
|
file = self.user_manager.get_request_user_filepath(
|
||||||
|
request,
|
||||||
|
"comfy.settings.json"
|
||||||
|
)
|
||||||
|
except KeyError as e:
|
||||||
|
logging.error("User settings not found.")
|
||||||
|
raise web.HTTPUnauthorized() from e
|
||||||
if os.path.isfile(file):
|
if os.path.isfile(file):
|
||||||
try:
|
try:
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
|
@ -79,6 +79,7 @@ fpte_group.add_argument("--fp8_e4m3fn-text-enc", action="store_true", help="Stor
|
|||||||
fpte_group.add_argument("--fp8_e5m2-text-enc", action="store_true", help="Store text encoder weights in fp8 (e5m2 variant).")
|
fpte_group.add_argument("--fp8_e5m2-text-enc", action="store_true", help="Store text encoder weights in fp8 (e5m2 variant).")
|
||||||
fpte_group.add_argument("--fp16-text-enc", action="store_true", help="Store text encoder weights in fp16.")
|
fpte_group.add_argument("--fp16-text-enc", action="store_true", help="Store text encoder weights in fp16.")
|
||||||
fpte_group.add_argument("--fp32-text-enc", action="store_true", help="Store text encoder weights in fp32.")
|
fpte_group.add_argument("--fp32-text-enc", action="store_true", help="Store text encoder weights in fp32.")
|
||||||
|
fpte_group.add_argument("--bf16-text-enc", action="store_true", help="Store text encoder weights in bf16.")
|
||||||
|
|
||||||
parser.add_argument("--force-channels-last", action="store_true", help="Force channels last format when inferencing the models.")
|
parser.add_argument("--force-channels-last", action="store_true", help="Force channels last format when inferencing the models.")
|
||||||
|
|
||||||
|
@ -823,6 +823,8 @@ def text_encoder_dtype(device=None):
|
|||||||
return torch.float8_e5m2
|
return torch.float8_e5m2
|
||||||
elif args.fp16_text_enc:
|
elif args.fp16_text_enc:
|
||||||
return torch.float16
|
return torch.float16
|
||||||
|
elif args.bf16_text_enc:
|
||||||
|
return torch.bfloat16
|
||||||
elif args.fp32_text_enc:
|
elif args.fp32_text_enc:
|
||||||
return torch.float32
|
return torch.float32
|
||||||
|
|
||||||
@ -1235,6 +1237,8 @@ def soft_empty_cache(force=False):
|
|||||||
torch.xpu.empty_cache()
|
torch.xpu.empty_cache()
|
||||||
elif is_ascend_npu():
|
elif is_ascend_npu():
|
||||||
torch.npu.empty_cache()
|
torch.npu.empty_cache()
|
||||||
|
elif is_mlu():
|
||||||
|
torch.mlu.empty_cache()
|
||||||
elif torch.cuda.is_available():
|
elif torch.cuda.is_available():
|
||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
torch.cuda.ipc_collect()
|
torch.cuda.ipc_collect()
|
||||||
|
@ -244,7 +244,7 @@ def save_glb(vertices, faces, filepath, metadata=None):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
vertices: torch.Tensor of shape (N, 3) - The vertex coordinates
|
vertices: torch.Tensor of shape (N, 3) - The vertex coordinates
|
||||||
faces: torch.Tensor of shape (M, 4) or (M, 3) - The face indices (quad or triangle faces)
|
faces: torch.Tensor of shape (M, 3) - The face indices (triangle faces)
|
||||||
filepath: str - Output filepath (should end with .glb)
|
filepath: str - Output filepath (should end with .glb)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import numpy as np
|
|||||||
import scipy.ndimage
|
import scipy.ndimage
|
||||||
import torch
|
import torch
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
import node_helpers
|
||||||
|
|
||||||
from nodes import MAX_RESOLUTION
|
from nodes import MAX_RESOLUTION
|
||||||
|
|
||||||
@ -87,11 +88,7 @@ class ImageCompositeMasked:
|
|||||||
CATEGORY = "image"
|
CATEGORY = "image"
|
||||||
|
|
||||||
def composite(self, destination, source, x, y, resize_source, mask = None):
|
def composite(self, destination, source, x, y, resize_source, mask = None):
|
||||||
if destination.shape[-1] < source.shape[-1]:
|
destination, source = node_helpers.image_alpha_fix(destination, source)
|
||||||
source = source[...,:destination.shape[-1]]
|
|
||||||
elif destination.shape[-1] > source.shape[-1]:
|
|
||||||
destination = torch.nn.functional.pad(destination, (0, 1))
|
|
||||||
destination[..., -1] = source[..., -1]
|
|
||||||
destination = destination.clone().movedim(-1, 1)
|
destination = destination.clone().movedim(-1, 1)
|
||||||
output = composite(destination, source.movedim(-1, 1), x, y, mask, 1, resize_source).movedim(1, -1)
|
output = composite(destination, source.movedim(-1, 1), x, y, mask, 1, resize_source).movedim(1, -1)
|
||||||
return (output,)
|
return (output,)
|
||||||
|
@ -6,7 +6,7 @@ import math
|
|||||||
|
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
import comfy.model_management
|
import comfy.model_management
|
||||||
|
import node_helpers
|
||||||
|
|
||||||
class Blend:
|
class Blend:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -34,6 +34,7 @@ class Blend:
|
|||||||
CATEGORY = "image/postprocessing"
|
CATEGORY = "image/postprocessing"
|
||||||
|
|
||||||
def blend_images(self, image1: torch.Tensor, image2: torch.Tensor, blend_factor: float, blend_mode: str):
|
def blend_images(self, image1: torch.Tensor, image2: torch.Tensor, blend_factor: float, blend_mode: str):
|
||||||
|
image1, image2 = node_helpers.image_alpha_fix(image1, image2)
|
||||||
image2 = image2.to(image1.device)
|
image2 = image2.to(image1.device)
|
||||||
if image1.shape != image2.shape:
|
if image1.shape != image2.shape:
|
||||||
image2 = image2.permute(0, 3, 1, 2)
|
image2 = image2.permute(0, 3, 1, 2)
|
||||||
|
@ -44,3 +44,11 @@ def string_to_torch_dtype(string):
|
|||||||
return torch.float16
|
return torch.float16
|
||||||
if string == "bf16":
|
if string == "bf16":
|
||||||
return torch.bfloat16
|
return torch.bfloat16
|
||||||
|
|
||||||
|
def image_alpha_fix(destination, source):
|
||||||
|
if destination.shape[-1] < source.shape[-1]:
|
||||||
|
source = source[...,:destination.shape[-1]]
|
||||||
|
elif destination.shape[-1] > source.shape[-1]:
|
||||||
|
destination = torch.nn.functional.pad(destination, (0, 1))
|
||||||
|
destination[..., -1] = source[..., -1]
|
||||||
|
return destination, source
|
||||||
|
Loading…
x
Reference in New Issue
Block a user