Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public record class ComfyCustomWorkflow(string Name, string Workflow, string Pro
["TeaCache"] = "teacache",
["TeaCacheForVidGen"] = "teacache",
["TeaCacheForImgGen"] = "teacache_oldvers",
["OverrideCLIPDevice"] = "set_clip_device"
["OverrideCLIPDevice"] = "set_clip_device",
["MinimaxH3LatentUpscaler3D"] = "minimax_h3_latent_upscaler"
};

/// <inheritdoc/>
Expand Down
125 changes: 94 additions & 31 deletions src/BuiltinExtensions/ComfyUIBackend/WorkflowGeneratorSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1699,48 +1699,111 @@ JArray doMaskShrinkApply(WorkflowGenerator g, JArray imgIn)
}
else if (doUpscale && upscaleMethod.StartsWith("latentmodel-"))
{
g.CreateNode("LatentUpscaleModelLoader", new JObject()
string modelName = upscaleMethod.After("latentmodel-");
if (g.IsMiniMaxH3())
{
["model_name"] = upscaleMethod.After("latentmodel-")
}, "27");
if (g.IsHunyuanVideo15())
{
g.CreateNode("HunyuanVideo15LatentUpscaleWithModel", new JObject()
width = (width / 32) * 32;
height = (height / 32) * 32;
if (!g.Features.Contains("minimax_h3_latent_upscaler"))
{
["model"] = NodePath("27", 0),
["samples"] = g.CurrentMedia.Path,
["upscale_method"] = "bilinear",
["width"] = width,
["height"] = height,
["crop"] = "disabled"
}, "26");
g.CurrentMedia = g.CurrentMedia.WithPath(["26", 0], WGNodeData.DT_LATENT_VIDEO);
}
else if (g.IsLTXV2())
{
g.CurrentMedia = g.CurrentMedia.AsLatentImage(g.CurrentVae);
string cropGuides = g.CreateNode("LTXVCropGuides", new JObject()
throw new SwarmUserErrorException("MiniMax H3 latent upscaling requires the Comfyui_Minimax_h3_latent_Upscaler node pack.");
}
JArray vidLatent;
JArray audLatent = null;
if (g.CurrentMedia.DataType == WGNodeData.DT_LATENT_AUDIOVIDEO)
{
["positive"] = prompt,
["negative"] = negPrompt,
["latent"] = g.CurrentMedia.Path
});
prompt = [cropGuides, 0];
negPrompt = [cropGuides, 1];
g.CreateNode("LTXVLatentUpsampler", new JObject()
string sepNode = g.CreateNode("LTXVSeparateAVLatent", new JObject()
{
["av_latent"] = g.CurrentMedia.Path
});
vidLatent = NodePath(sepNode, 0);
audLatent = NodePath(sepNode, 1);
}
else
{
["vae"] = g.CurrentVae.Path,
["samples"] = NodePath(cropGuides, 2),
["upscale_model"] = NodePath("27", 0)
vidLatent = g.CurrentMedia.Path;
if (g.CurrentMedia.AttachedAudio is not null)
{
audLatent = g.CurrentMedia.AttachedAudio.Path;
}
}
string upscaleNode = g.CreateNode("MinimaxH3LatentUpscaler3D", new JObject()
{
["latent"] = vidLatent,
["model_name"] = modelName,
["mode"] = "scale by multiplier",
["mode.scale"] = refineUpscale,
["align"] = 32,
["enable_temporal_chunking"] = true,
["force_unload"] = true,
["device"] = "cuda",
["precision"] = "fp16"
}, "26");
g.CurrentMedia = g.CurrentMedia.WithPath(["26", 0], WGNodeData.DT_LATENT_VIDEO);
if (audLatent is not null)
{
string concatNode = g.CreateNode("LTXVConcatAVLatent", new JObject()
{
["video_latent"] = NodePath(upscaleNode, 0),
["audio_latent"] = audLatent
});
g.CurrentMedia = g.CurrentMedia.WithPath([concatNode, 0], WGNodeData.DT_LATENT_AUDIOVIDEO);
g.CurrentMedia.AttachedAudio = null;
}
else
{
g.CurrentMedia = g.CurrentMedia.WithPath([upscaleNode, 0], WGNodeData.DT_LATENT_VIDEO);
}
}
else
{
throw new SwarmUserErrorException($"Cannot latent-upscale with a model for {g.CurrentCompatClass()}, check your Refiner Upscale Method parameter");
g.CreateNode("LatentUpscaleModelLoader", new JObject()
{
["model_name"] = modelName
}, "27");
if (g.IsHunyuanVideo15())
{
g.CreateNode("HunyuanVideo15LatentUpscaleWithModel", new JObject()
{
["model"] = NodePath("27", 0),
["samples"] = g.CurrentMedia.Path,
["upscale_method"] = "bilinear",
["width"] = width,
["height"] = height,
["crop"] = "disabled"
}, "26");
g.CurrentMedia = g.CurrentMedia.WithPath(["26", 0], WGNodeData.DT_LATENT_VIDEO);
}
else if (g.IsLTXV2())
{
g.CurrentMedia = g.CurrentMedia.AsLatentImage(g.CurrentVae);
string cropGuides = g.CreateNode("LTXVCropGuides", new JObject()
{
["positive"] = prompt,
["negative"] = negPrompt,
["latent"] = g.CurrentMedia.Path
});
prompt = [cropGuides, 0];
negPrompt = [cropGuides, 1];
g.CreateNode("LTXVLatentUpsampler", new JObject()
{
["vae"] = g.CurrentVae.Path,
["samples"] = NodePath(cropGuides, 2),
["upscale_model"] = NodePath("27", 0)
}, "26");
g.CurrentMedia = g.CurrentMedia.WithPath(["26", 0], WGNodeData.DT_LATENT_VIDEO);
}
else
{
throw new SwarmUserErrorException($"Cannot latent-upscale with a model for {g.CurrentCompatClass()}, check your Refiner Upscale Method parameter");
}
}
g.CurrentMedia.Width = width;
g.CurrentMedia.Height = height;
if (refinerControl <= 0)
{
g.IsRefinerStage = false;
return;
}
}
if (isSeedVr)
{
Expand Down
1 change: 1 addition & 0 deletions src/Core/InstallableFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ static InstallableFeatures()
RegisterInstallableFeature(new("ExtraModels", "extramodels", "https://github.com/city96/ComfyUI_ExtraModels", "city96", "This will install ExtraModels support developed by city96.\nDo you wish to install?"));
RegisterInstallableFeature(new("Nunchaku", "nunchaku", "https://github.com/mit-han-lab/ComfyUI-nunchaku", "mit-han-lab"));
RegisterInstallableFeature(new("TeaCache", "teacache", "https://github.com/welltop-cn/ComfyUI-TeaCache", "welltop-cn"));
RegisterInstallableFeature(new("MiniMax H3 Latent Upscaler", "minimax_h3_latent_upscaler", "https://github.com/LBH-123-AI/Comfyui_Minimax_h3_latent_Upscaler", "LBH-123-AI"));
}
}