Skip to content

Commit

Permalink
Merge pull request #810 from LykosAI/main
Browse files Browse the repository at this point in the history
v2.11.6
  • Loading branch information
mohnjiles authored Aug 9, 2024
2 parents 8aa9586 + 21f51a2 commit 77fd96b
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 162 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to Stability Matrix will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html).

## v2.11.6
### Fixed
- Fixed incorrect IPAdapter download links in the HuggingFace model browser
- Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions
- Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata
- Fixed [#795](https://github.com/LykosAI/StabilityMatrix/issues/795) - SwarmUI launch args not working properly
- Fixed [#745](https://github.com/LykosAI/StabilityMatrix/issues/745) - not passing Environment Variables to SwarmUI
### Supporters
#### Visionaries
- Shoutout to our Visionary-tier Patreon supporter, **Scopp Mcdee**! Huge thanks for your continued support!
#### Pioneers
- Many thanks to our Pioneer-tier supporters on Patreon: **tankfox**, **tanangular**, **Mr. Unknown**, and **Szir777**! Your continued support is greatly appreciated!

## v2.11.5
### Added
Expand Down
27 changes: 7 additions & 20 deletions StabilityMatrix.Avalonia/Assets/hf-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,16 @@
"ModelName": "SD 1.5 Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_sd15",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter_sd15.safetensors"
],
"Subfolder": "ip_adapter_sd15",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapter",
"ModelName": "SD 1.5 Light Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_sd15_light",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter_sd15_light.safetensors"
],
"Subfolder": "ip_adapter_sd15_light",
"LicenseType": "Apache 2.0"
Expand All @@ -412,54 +409,44 @@
"ModelName": "SD 1.5 Plus Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_plus_sd15",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter-plus_sd15.safetensors"
],
"Subfolder": "ip_adapter_plus_sd15",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapter",
"ModelName": "SD 1.5 Face Plus Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_plus_face_sd15",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter-plus-face_sd15.safetensors"
],
"Subfolder": "ip_adapter_plus_face_sd15",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapterXl",
"ModelName": "SDXL Adapter",
"RepositoryPath": "InvokeAI/ip_adapter_sdxl",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter_sdxl.safetensors"
],
"Subfolder": "ip_adapter_sdxl",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapterXl",
"ModelName": "SDXL Plus Adapter",
"RepositoryPath": "InvokeAI/ip-adapter-plus_sdxl_vit-h",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter-plus_sdxl_vit-h.safetensors"
],
"Subfolder": "ip_adapter_plus_sdxl_vit-h",
"LicenseType": "Apache 2.0"
},
{
"ModelCategory": "DiffusersIpAdapterXl",
"ModelName": "SDXL Face Plus Adapter",
"RepositoryPath": "InvokeAI/ip-adapter-plus-face_sdxl_vit-h",
"Files": [
"image_encoder.txt",
"ip_adapter.bin"
"ip-adapter-plus-face_sdxl_vit-h.safetensors"
],
"Subfolder": "ip_adapter_plus_face_sdxl_vit-h",
"LicenseType": "CreativeML Open RAIL-M"
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Reactive.Disposables;
using JetBrains.Annotations;

namespace StabilityMatrix.Avalonia.ViewModels.Base;

public abstract class DisposableLoadableViewModelBase : LoadableViewModelBase, IDisposable
{
private readonly CompositeDisposable instanceDisposables = new();

/// <summary>
/// Adds a disposable to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposable">The disposable to add.</param>
protected void AddDisposable([HandlesResourceDisposal] IDisposable disposable)
{
instanceDisposables.Add(disposable);
}

/// <summary>
/// Adds disposables to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposables">The disposables to add.</param>
protected void AddDisposable([HandlesResourceDisposal] params IDisposable[] disposables)
{
foreach (var disposable in disposables)
{
instanceDisposables.Add(disposable);
}
}

/// <summary>
/// Adds a disposable to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposable">The disposable to add.</param>
/// <typeparam name="T">The type of the disposable.</typeparam>
/// <returns>The disposable that was added.</returns>
protected T AddDisposable<T>([HandlesResourceDisposal] T disposable)
where T : IDisposable
{
instanceDisposables.Add(disposable);
return disposable;
}

/// <summary>
/// Adds disposables to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposables">The disposables to add.</param>
/// <typeparam name="T">The type of the disposables.</typeparam>
/// <returns>The disposables that were added.</returns>
protected T[] AddDisposable<T>([HandlesResourceDisposal] params T[] disposables)
where T : IDisposable
{
foreach (var disposable in disposables)
{
instanceDisposables.Add(disposable);
}

return disposables;
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
instanceDisposables.Dispose();
}
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Reactive.Disposables;
using JetBrains.Annotations;

namespace StabilityMatrix.Avalonia.ViewModels.Base;

public abstract class DisposableViewModelBase : ViewModelBase, IDisposable
{
private readonly CompositeDisposable instanceDisposables = new();

/// <summary>
/// Adds a disposable to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposable">The disposable to add.</param>
protected void AddDisposable([HandlesResourceDisposal] IDisposable disposable)
{
instanceDisposables.Add(disposable);
}

/// <summary>
/// Adds disposables to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposables">The disposables to add.</param>
protected void AddDisposable([HandlesResourceDisposal] params IDisposable[] disposables)
{
foreach (var disposable in disposables)
{
instanceDisposables.Add(disposable);
}
}

/// <summary>
/// Adds a disposable to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposable">The disposable to add.</param>
/// <typeparam name="T">The type of the disposable.</typeparam>
/// <returns>The disposable that was added.</returns>
protected T AddDisposable<T>([HandlesResourceDisposal] T disposable)
where T : IDisposable
{
instanceDisposables.Add(disposable);
return disposable;
}

/// <summary>
/// Adds disposables to be disposed when this view model is disposed.
/// </summary>
/// <param name="disposables">The disposables to add.</param>
/// <typeparam name="T">The type of the disposables.</typeparam>
/// <returns>The disposables that were added.</returns>
protected T[] AddDisposable<T>([HandlesResourceDisposal] params T[] disposables)
where T : IDisposable
{
foreach (var disposable in disposables)
{
instanceDisposables.Add(disposable);
}

return disposables;
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
instanceDisposables.Dispose();
}
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ RunningPackageService runningPackageService
ClientManager = inferenceClientManager;

ImageGalleryCardViewModel = vmFactory.Get<ImageGalleryCardViewModel>();
ImageFolderCardViewModel = vmFactory.Get<ImageFolderCardViewModel>();
ImageFolderCardViewModel = AddDisposable(vmFactory.Get<ImageFolderCardViewModel>());

GenerateImageCommand.WithConditionalNotificationErrorHandler(notificationService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
namespace StabilityMatrix.Avalonia.ViewModels.Base;

public abstract partial class InferenceTabViewModelBase
: LoadableViewModelBase,
IDisposable,
: DisposableLoadableViewModelBase,
IPersistentViewProvider,
IDropTarget
{
Expand Down Expand Up @@ -158,21 +157,16 @@ private async Task DebugLoadViewState()
}
}

protected virtual void Dispose(bool disposing)
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (disposing)
{
((IPersistentViewProvider)this).AttachedPersistentView = null;
}
}

/// <inheritdoc />
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Loads image and metadata from a file path
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(ImageFolderCard))]
[ManagedService]
[Transient]
public partial class ImageFolderCardViewModel : ViewModelBase
public partial class ImageFolderCardViewModel : DisposableViewModelBase
{
private readonly ILogger<ImageFolderCardViewModel> logger;
private readonly IImageIndexService imageIndexService;
Expand Down Expand Up @@ -83,11 +83,13 @@ INotificationService notificationService
.Bind(LocalImages)
.Subscribe();

settingsManager.RelayPropertyFor(
this,
vm => vm.ImageSize,
settings => settings.InferenceImageSize,
delay: TimeSpan.FromMilliseconds(250)
AddDisposable(
settingsManager.RelayPropertyFor(
this,
vm => vm.ImageSize,
settings => settings.InferenceImageSize,
delay: TimeSpan.FromMilliseconds(250)
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ RunningPackageService runningPackageService
samplerCard.DenoiseStrength = 1.0d;
});

PromptCardViewModel = vmFactory.Get<PromptCardViewModel>();
PromptCardViewModel = AddDisposable(vmFactory.Get<PromptCardViewModel>());

BatchSizeCardViewModel = vmFactory.Get<BatchSizeCardViewModel>();

ModulesCardViewModel = vmFactory.Get<StackEditableCardViewModel>(modulesCard =>
Expand All @@ -108,13 +109,15 @@ RunningPackageService runningPackageService
);

// When refiner is provided in model card, enable for sampler
ModelCardViewModel
.WhenPropertyChanged(x => x.IsRefinerSelectionEnabled)
.Subscribe(e =>
{
SamplerCardViewModel.IsRefinerStepsEnabled =
e.Sender is { IsRefinerSelectionEnabled: true, SelectedRefiner: not null };
});
AddDisposable(
ModelCardViewModel
.WhenPropertyChanged(x => x.IsRefinerSelectionEnabled)
.Subscribe(e =>
{
SamplerCardViewModel.IsRefinerStepsEnabled =
e.Sender is { IsRefinerSelectionEnabled: true, SelectedRefiner: not null };
})
);
}

/// <inheritdoc />
Expand Down Expand Up @@ -211,13 +214,23 @@ CancellationToken cancellationToken
var buildPromptArgs = new BuildPromptEventArgs { Overrides = overrides, SeedOverride = seed };
BuildPrompt(buildPromptArgs);

// update seed in project for batches
var inferenceProject = InferenceProjectDocument.FromLoadable(this);
if (inferenceProject.State?["Seed"]?["Seed"] is not null)
{
inferenceProject = inferenceProject.WithState(x => x["Seed"]["Seed"] = seed);
}

var generationArgs = new ImageGenerationEventArgs
{
Client = ClientManager.Client,
Nodes = buildPromptArgs.Builder.ToNodeDictionary(),
OutputNodeNames = buildPromptArgs.Builder.Connections.OutputNodeNames.ToArray(),
Parameters = SaveStateToParameters(new GenerationParameters()),
Project = InferenceProjectDocument.FromLoadable(this),
Parameters = SaveStateToParameters(new GenerationParameters()) with
{
Seed = Convert.ToUInt64(seed)
},
Project = inferenceProject,
FilesToTransfer = buildPromptArgs.FilesToTransfer,
BatchIndex = i,
// Only clear output images on the first batch
Expand Down
Loading

0 comments on commit 77fd96b

Please sign in to comment.