forked from LykosAI/StabilityMatrix-Dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTiledVAEModule.cs
More file actions
61 lines (50 loc) · 2.09 KB
/
TiledVAEModule.cs
File metadata and controls
61 lines (50 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Injectio.Attributes;
using StabilityMatrix.Avalonia.Models.Inference;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Models.Api.Comfy.Nodes;
using NLog;
namespace StabilityMatrix.Avalonia.ViewModels.Inference.Modules;
[ManagedService]
[RegisterTransient<TiledVAEModule>]
public class TiledVAEModule : ModuleBase
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public TiledVAEModule(IServiceManager<ViewModelBase> vmFactory)
: base(vmFactory)
{
Title = "Tiled VAE Decode";
AddCards(vmFactory.Get<TiledVAECardViewModel>());
}
protected override void OnApplyStep(ModuleApplyStepEventArgs e)
{
var card = GetCard<TiledVAECardViewModel>();
e.PreOutputActions.Add(args =>
{
var builder = args.Builder;
// Only apply if primary is in latent space
if (builder.Connections.Primary?.IsT0 != true)
return;
var latent = builder.Connections.Primary.AsT0;
var vae = builder.Connections.GetDefaultVAE();
logger.Debug("TiledVAE: Injecting TiledVAEDecode");
logger.Debug("UseCustomTemporalTiling value at runtime: {value}", card.UseCustomTemporalTiling);
var node = builder.Nodes.AddTypedNode(
new ComfyNodeBuilder.TiledVAEDecode
{
Name = builder.Nodes.GetUniqueName("TiledVAEDecode"),
Samples = latent,
Vae = vae,
TileSize = card.TileSize,
Overlap = card.Overlap,
// Temporal tiling (WAN requires temporal tiling)
TemporalSize = card.UseCustomTemporalTiling ? card.TemporalSize : 64,
TemporalOverlap = card.UseCustomTemporalTiling ? card.TemporalOverlap : 8,
}
);
// Update primary connection to the decoded image
builder.Connections.Primary = node.Output;
});
}
}