mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-15 16:02:32 +08:00
Merge branch 'comfyanonymous:master' into batched_noise
This commit is contained in:
commit
197cad9ceb
@ -303,7 +303,7 @@ class SVD_img2vid(BaseModel):
|
|||||||
if latent_image.shape[1:] != noise.shape[1:]:
|
if latent_image.shape[1:] != noise.shape[1:]:
|
||||||
latent_image = utils.common_upscale(latent_image, noise.shape[-1], noise.shape[-2], "bilinear", "center")
|
latent_image = utils.common_upscale(latent_image, noise.shape[-1], noise.shape[-2], "bilinear", "center")
|
||||||
|
|
||||||
latent_image = utils.repeat_to_batch_size(latent_image, noise.shape[0])
|
latent_image = utils.resize_to_batch_size(latent_image, noise.shape[0])
|
||||||
|
|
||||||
out['c_concat'] = comfy.conds.CONDNoiseShape(latent_image)
|
out['c_concat'] = comfy.conds.CONDNoiseShape(latent_image)
|
||||||
|
|
||||||
|
|||||||
@ -239,6 +239,26 @@ def repeat_to_batch_size(tensor, batch_size):
|
|||||||
return tensor.repeat([math.ceil(batch_size / tensor.shape[0])] + [1] * (len(tensor.shape) - 1))[:batch_size]
|
return tensor.repeat([math.ceil(batch_size / tensor.shape[0])] + [1] * (len(tensor.shape) - 1))[:batch_size]
|
||||||
return tensor
|
return tensor
|
||||||
|
|
||||||
|
def resize_to_batch_size(tensor, batch_size):
|
||||||
|
in_batch_size = tensor.shape[0]
|
||||||
|
if in_batch_size == batch_size:
|
||||||
|
return tensor
|
||||||
|
|
||||||
|
if batch_size <= 1:
|
||||||
|
return tensor[:batch_size]
|
||||||
|
|
||||||
|
output = torch.empty([batch_size] + list(tensor.shape)[1:], dtype=tensor.dtype, device=tensor.device)
|
||||||
|
if batch_size < in_batch_size:
|
||||||
|
scale = (in_batch_size - 1) / (batch_size - 1)
|
||||||
|
for i in range(batch_size):
|
||||||
|
output[i] = tensor[min(round(i * scale), in_batch_size - 1)]
|
||||||
|
else:
|
||||||
|
scale = in_batch_size / batch_size
|
||||||
|
for i in range(batch_size):
|
||||||
|
output[i] = tensor[min(math.floor((i + 0.5) * scale), in_batch_size - 1)]
|
||||||
|
|
||||||
|
return output
|
||||||
|
|
||||||
def convert_sd_to(state_dict, dtype):
|
def convert_sd_to(state_dict, dtype):
|
||||||
keys = list(state_dict.keys())
|
keys = list(state_dict.keys())
|
||||||
for k in keys:
|
for k in keys:
|
||||||
|
|||||||
@ -1878,6 +1878,8 @@ export class ComfyApp {
|
|||||||
if (pngInfo) {
|
if (pngInfo) {
|
||||||
if (pngInfo.workflow) {
|
if (pngInfo.workflow) {
|
||||||
await this.loadGraphData(JSON.parse(pngInfo.workflow));
|
await this.loadGraphData(JSON.parse(pngInfo.workflow));
|
||||||
|
} else if (pngInfo.prompt) {
|
||||||
|
this.loadApiJson(JSON.parse(pngInfo.prompt));
|
||||||
} else if (pngInfo.parameters) {
|
} else if (pngInfo.parameters) {
|
||||||
importA1111(this.graph, pngInfo.parameters);
|
importA1111(this.graph, pngInfo.parameters);
|
||||||
}
|
}
|
||||||
@ -1889,6 +1891,8 @@ export class ComfyApp {
|
|||||||
this.loadGraphData(JSON.parse(pngInfo.workflow));
|
this.loadGraphData(JSON.parse(pngInfo.workflow));
|
||||||
} else if (pngInfo.Workflow) {
|
} else if (pngInfo.Workflow) {
|
||||||
this.loadGraphData(JSON.parse(pngInfo.Workflow)); // Support loading workflows from that webp custom node.
|
this.loadGraphData(JSON.parse(pngInfo.Workflow)); // Support loading workflows from that webp custom node.
|
||||||
|
} else if (pngInfo.prompt) {
|
||||||
|
this.loadApiJson(JSON.parse(pngInfo.prompt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (file.type === "application/json" || file.name?.endsWith(".json")) {
|
} else if (file.type === "application/json" || file.name?.endsWith(".json")) {
|
||||||
@ -1908,6 +1912,8 @@ export class ComfyApp {
|
|||||||
const info = await getLatentMetadata(file);
|
const info = await getLatentMetadata(file);
|
||||||
if (info.workflow) {
|
if (info.workflow) {
|
||||||
await this.loadGraphData(JSON.parse(info.workflow));
|
await this.loadGraphData(JSON.parse(info.workflow));
|
||||||
|
} else if (info.prompt) {
|
||||||
|
this.loadApiJson(JSON.parse(info.prompt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user