mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-07 07:42:32 +08:00
Merge branch 'master' into feature/has-intermediate-output
This commit is contained in:
commit
207a689bc6
@ -890,7 +890,7 @@ class Flux(BaseModel):
|
|||||||
return torch.cat((image, mask), dim=1)
|
return torch.cat((image, mask), dim=1)
|
||||||
|
|
||||||
def encode_adm(self, **kwargs):
|
def encode_adm(self, **kwargs):
|
||||||
return kwargs["pooled_output"]
|
return kwargs.get("pooled_output", None)
|
||||||
|
|
||||||
def extra_conds(self, **kwargs):
|
def extra_conds(self, **kwargs):
|
||||||
out = super().extra_conds(**kwargs)
|
out = super().extra_conds(**kwargs)
|
||||||
|
|||||||
@ -201,6 +201,16 @@ async def get_image_from_response(response: GeminiGenerateContentResponse, thoug
|
|||||||
returned_image = await download_url_to_image_tensor(part.fileData.fileUri)
|
returned_image = await download_url_to_image_tensor(part.fileData.fileUri)
|
||||||
image_tensors.append(returned_image)
|
image_tensors.append(returned_image)
|
||||||
if len(image_tensors) == 0:
|
if len(image_tensors) == 0:
|
||||||
|
if not thought:
|
||||||
|
# No images generated --> extract text response for a meaningful error
|
||||||
|
model_message = get_text_from_response(response).strip()
|
||||||
|
if model_message:
|
||||||
|
raise ValueError(f"Gemini did not generate an image. Model response: {model_message}")
|
||||||
|
raise ValueError(
|
||||||
|
"Gemini did not generate an image. "
|
||||||
|
"Try rephrasing your prompt or changing the response modality to 'IMAGE+TEXT' "
|
||||||
|
"to see the model's reasoning."
|
||||||
|
)
|
||||||
return torch.zeros((1, 1024, 1024, 4))
|
return torch.zeros((1, 1024, 1024, 4))
|
||||||
return torch.cat(image_tensors, dim=0)
|
return torch.cat(image_tensors, dim=0)
|
||||||
|
|
||||||
|
|||||||
@ -67,11 +67,11 @@ class Blend(io.ComfyNode):
|
|||||||
def g(cls, x):
|
def g(cls, x):
|
||||||
return torch.where(x <= 0.25, ((16 * x - 12) * x + 4) * x, torch.sqrt(x))
|
return torch.where(x <= 0.25, ((16 * x - 12) * x + 4) * x, torch.sqrt(x))
|
||||||
|
|
||||||
def gaussian_kernel(kernel_size: int, sigma: float, device=None):
|
def gaussian_kernel(kernel_size: int, sigma: float, device=None, dtype=torch.float32):
|
||||||
x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size, device=device), torch.linspace(-1, 1, kernel_size, device=device), indexing="ij")
|
x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size, device=device), torch.linspace(-1, 1, kernel_size, device=device), indexing="ij")
|
||||||
d = torch.sqrt(x * x + y * y)
|
d = torch.sqrt(x * x + y * y)
|
||||||
g = torch.exp(-(d * d) / (2.0 * sigma * sigma))
|
g = torch.exp(-(d * d) / (2.0 * sigma * sigma))
|
||||||
return g / g.sum()
|
return (g / g.sum()).to(dtype)
|
||||||
|
|
||||||
class Blur(io.ComfyNode):
|
class Blur(io.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -99,7 +99,7 @@ class Blur(io.ComfyNode):
|
|||||||
batch_size, height, width, channels = image.shape
|
batch_size, height, width, channels = image.shape
|
||||||
|
|
||||||
kernel_size = blur_radius * 2 + 1
|
kernel_size = blur_radius * 2 + 1
|
||||||
kernel = gaussian_kernel(kernel_size, sigma, device=image.device).repeat(channels, 1, 1).unsqueeze(1)
|
kernel = gaussian_kernel(kernel_size, sigma, device=image.device, dtype=image.dtype).repeat(channels, 1, 1).unsqueeze(1)
|
||||||
|
|
||||||
image = image.permute(0, 3, 1, 2) # Torch wants (B, C, H, W) we use (B, H, W, C)
|
image = image.permute(0, 3, 1, 2) # Torch wants (B, C, H, W) we use (B, H, W, C)
|
||||||
padded_image = F.pad(image, (blur_radius,blur_radius,blur_radius,blur_radius), 'reflect')
|
padded_image = F.pad(image, (blur_radius,blur_radius,blur_radius,blur_radius), 'reflect')
|
||||||
@ -200,7 +200,7 @@ class Sharpen(io.ComfyNode):
|
|||||||
image = image.to(comfy.model_management.get_torch_device())
|
image = image.to(comfy.model_management.get_torch_device())
|
||||||
|
|
||||||
kernel_size = sharpen_radius * 2 + 1
|
kernel_size = sharpen_radius * 2 + 1
|
||||||
kernel = gaussian_kernel(kernel_size, sigma, device=image.device) * -(alpha*10)
|
kernel = gaussian_kernel(kernel_size, sigma, device=image.device, dtype=image.dtype) * -(alpha*10)
|
||||||
kernel = kernel.to(dtype=image.dtype)
|
kernel = kernel.to(dtype=image.dtype)
|
||||||
center = kernel_size // 2
|
center = kernel_size // 2
|
||||||
kernel[center, center] = kernel[center, center] - kernel.sum() + 1.0
|
kernel[center, center] = kernel[center, center] - kernel.sum() + 1.0
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
comfyui-frontend-package==1.42.8
|
comfyui-frontend-package==1.42.8
|
||||||
comfyui-workflow-templates==0.9.38
|
comfyui-workflow-templates==0.9.39
|
||||||
comfyui-embedded-docs==0.4.3
|
comfyui-embedded-docs==0.4.3
|
||||||
torch
|
torch
|
||||||
torchsde
|
torchsde
|
||||||
|
|||||||
@ -24,6 +24,7 @@ def init_mime_types():
|
|||||||
# Web types (used by server.py for static file serving)
|
# Web types (used by server.py for static file serving)
|
||||||
mimetypes.add_type('application/javascript; charset=utf-8', '.js')
|
mimetypes.add_type('application/javascript; charset=utf-8', '.js')
|
||||||
mimetypes.add_type('image/webp', '.webp')
|
mimetypes.add_type('image/webp', '.webp')
|
||||||
|
mimetypes.add_type('image/svg+xml', '.svg')
|
||||||
|
|
||||||
# Model and data file types (used by asset scanning / metadata extraction)
|
# Model and data file types (used by asset scanning / metadata extraction)
|
||||||
mimetypes.add_type("application/safetensors", ".safetensors")
|
mimetypes.add_type("application/safetensors", ".safetensors")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user