-
-
Notifications
You must be signed in to change notification settings - Fork 499
Add Feature - Tiled VAE Decode to Inference #1469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
36fb141
Add Feature - Tiled VAE module for Inference
NeuralFault 9b7734b
Change title from 'Tiled VAE' to 'Tiled VAE Decode'
NeuralFault e82e691
Add SmallChange and LargeChange to NumberBox
NeuralFault c598bce
Adjust Margin for NumberBox controls in TiledVAECard
NeuralFault File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
StabilityMatrix.Avalonia/Controls/Inference/TiledVAECard.axaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <Styles | ||
| xmlns="https://github.com/avaloniaui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:controls="using:StabilityMatrix.Avalonia.Controls" | ||
| xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" | ||
| xmlns:vmInference="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Inference" | ||
| x:DataType="vmInference:TiledVAECardViewModel"> | ||
| <Design.PreviewWith> | ||
| <controls:TiledVAECard /> | ||
| </Design.PreviewWith> | ||
|
|
||
| <Style Selector="controls|TiledVAECard"> | ||
| <!-- Set Defaults --> | ||
| <Setter Property="Template"> | ||
| <ControlTemplate> | ||
| <controls:Card x:Name="PART_Card"> | ||
| <controls:Card.Styles> | ||
| <Style Selector="ui|NumberBox"> | ||
| <Setter Property="Margin" Value="12,4,0,4" /> | ||
| <Setter Property="MinWidth" Value="70" /> | ||
| <Setter Property="HorizontalAlignment" Value="Stretch" /> | ||
| <Setter Property="ValidationMode" Value="InvalidInputOverwritten" /> | ||
| <Setter Property="SmallChange" Value="32" /> | ||
| <Setter Property="LargeChange" Value="128" /> | ||
| <Setter Property="SpinButtonPlacementMode" Value="Inline" /> | ||
| </Style> | ||
| </controls:Card.Styles> | ||
| <StackPanel Spacing="8"> | ||
| <!-- Tile Size --> | ||
| <Grid ColumnDefinitions="Auto,*"> | ||
| <TextBlock | ||
| Grid.Column="0" | ||
| VerticalAlignment="Center" | ||
| Text="Tile Size" /> | ||
| <ui:NumberBox | ||
| Grid.Column="1" | ||
| Margin="12,0,0,0" | ||
NeuralFault marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Value="{Binding TileSize, Mode=TwoWay}" /> | ||
| </Grid> | ||
|
|
||
| <!-- Overlap --> | ||
| <Grid ColumnDefinitions="Auto,*"> | ||
| <TextBlock | ||
| Grid.Column="0" | ||
| VerticalAlignment="Center" | ||
| Text="Overlap" /> | ||
| <ui:NumberBox | ||
| Grid.Column="1" | ||
| Margin="12,0,0,0" | ||
| Value="{Binding Overlap, Mode=TwoWay}" /> | ||
| </Grid> | ||
|
|
||
| <!-- Temporal Size (for Video VAEs) --> | ||
| <Grid ColumnDefinitions="Auto,*"> | ||
| <TextBlock | ||
| Grid.Column="0" | ||
| VerticalAlignment="Center" | ||
| Text="Temporal Size" /> | ||
| <ui:NumberBox | ||
| Grid.Column="1" | ||
| Margin="12,0,0,0" | ||
| Value="{Binding TemporalSize, Mode=TwoWay}" /> | ||
| </Grid> | ||
|
|
||
| <!-- Temporal Overlap (for Video VAEs) --> | ||
| <Grid ColumnDefinitions="Auto,*"> | ||
| <TextBlock | ||
| Grid.Column="0" | ||
| VerticalAlignment="Center" | ||
| Text="Temporal Overlap" /> | ||
| <ui:NumberBox | ||
| Grid.Column="1" | ||
| Margin="12,0,0,0" | ||
| Value="{Binding TemporalOverlap, Mode=TwoWay}" /> | ||
NeuralFault marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </Grid> | ||
| </StackPanel> | ||
| </controls:Card> | ||
| </ControlTemplate> | ||
| </Setter> | ||
| </Style> | ||
| </Styles> | ||
9 changes: 9 additions & 0 deletions
9
StabilityMatrix.Avalonia/Controls/Inference/TiledVAECard.axaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using Avalonia; | ||
| using Avalonia.Controls; | ||
| using Avalonia.Controls.Primitives; | ||
| using Injectio.Attributes; | ||
|
|
||
| namespace StabilityMatrix.Avalonia.Controls; | ||
|
|
||
| [RegisterTransient<TiledVAECard>] | ||
| public class TiledVAECard : TemplatedControlBase { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
StabilityMatrix.Avalonia/ViewModels/Inference/Modules/TiledVAEModule.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| 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; | ||
|
|
||
| namespace StabilityMatrix.Avalonia.ViewModels.Inference.Modules; | ||
|
|
||
| [ManagedService] | ||
| [RegisterTransient<TiledVAEModule>] | ||
| public class TiledVAEModule : ModuleBase | ||
| { | ||
| 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>(); | ||
|
|
||
| // Register a pre-output action that replaces standard VAE decode with tiled decode | ||
| 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(); | ||
|
|
||
| // Use tiled VAE decode instead of standard decode | ||
| var tiledDecode = builder.Nodes.AddTypedNode( | ||
| new ComfyNodeBuilder.TiledVAEDecode | ||
| { | ||
| Name = builder.Nodes.GetUniqueName("TiledVAEDecode"), | ||
| Samples = latent, | ||
| Vae = vae, | ||
| TileSize = card.TileSize, | ||
| Overlap = card.Overlap, | ||
| TemporalSize = card.TemporalSize, | ||
| TemporalOverlap = card.TemporalOverlap | ||
| } | ||
| ); | ||
|
|
||
| // Update primary connection to the decoded image | ||
| builder.Connections.Primary = tiledDecode.Output; | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
StabilityMatrix.Avalonia/ViewModels/Inference/TiledVAECardViewModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
| using CommunityToolkit.Mvvm.ComponentModel; | ||
| using Injectio.Attributes; | ||
| using StabilityMatrix.Avalonia.Controls; | ||
| using StabilityMatrix.Avalonia.ViewModels.Base; | ||
| using StabilityMatrix.Core.Attributes; | ||
|
|
||
| namespace StabilityMatrix.Avalonia.ViewModels.Inference; | ||
|
|
||
| [View(typeof(TiledVAECard))] | ||
| [ManagedService] | ||
| [RegisterTransient<TiledVAECardViewModel>] | ||
| public partial class TiledVAECardViewModel : LoadableViewModelBase | ||
| { | ||
| public const string ModuleKey = "TiledVAE"; | ||
|
|
||
| [ObservableProperty] | ||
| [NotifyDataErrorInfo] | ||
| [Required] | ||
| [Range(64, 4096)] | ||
| private int tileSize = 512; | ||
|
|
||
| [ObservableProperty] | ||
| [NotifyDataErrorInfo] | ||
| [Required] | ||
| [Range(0, 4096)] | ||
| private int overlap = 64; | ||
|
|
||
| [ObservableProperty] | ||
| [NotifyDataErrorInfo] | ||
| [Required] | ||
| [Range(8, 4096)] | ||
| private int temporalSize = 64; | ||
|
|
||
| [ObservableProperty] | ||
| [NotifyDataErrorInfo] | ||
| [Required] | ||
| [Range(4, 4096)] | ||
| private int temporalOverlap = 8; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.