Browse Source

disable existing huggingface download checkmark button things

pull/438/head
JT 10 months ago
parent
commit
5d7f8dff53
  1. 3
      CHANGELOG.md
  2. 8
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/HuggingFacePageViewModel.cs
  3. 10
      StabilityMatrix.Avalonia/ViewModels/HuggingFacePage/CategoryViewModel.cs
  4. 17
      StabilityMatrix.Avalonia/ViewModels/HuggingFacePage/HuggingfaceItemViewModel.cs
  5. 1
      StabilityMatrix.Avalonia/Views/HuggingFacePage.axaml

3
CHANGELOG.md

@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
- Added base model filter to Checkpoints page - Added base model filter to Checkpoints page
- Search box on Checkpoints page now searches tags and trigger words - Search box on Checkpoints page now searches tags and trigger words
- Added "Compatible Images" category when selecting images for Inference projects - Added "Compatible Images" category when selecting images for Inference projects
### Changed
- Removed "Failed to load image" notification when loading some images on the Checkpoints page
- Installed models will no longer be selectable on the Hugging Face tab of the model browser
### Fixed ### Fixed
- Inference file name patterns with directory separator characters will now have the subdirectories created automatically - Inference file name patterns with directory separator characters will now have the subdirectories created automatically
- Fixed missing up/downgrade buttons on the Python Packages dialog when the version was not semver compatible - Fixed missing up/downgrade buttons on the Python Packages dialog when the version was not semver compatible

8
StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/HuggingFacePageViewModel.cs

@ -8,6 +8,7 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
using Avalonia; using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications; using Avalonia.Controls.Notifications;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Input; using Avalonia.Input;
@ -79,7 +80,10 @@ public partial class HuggingFacePageViewModel : TabViewModelBase
.Group(i => i.ModelCategory) .Group(i => i.ModelCategory)
.Transform( .Transform(
g => g =>
new CategoryViewModel(g.Cache.Items) new CategoryViewModel(
g.Cache.Items,
Design.IsDesignMode ? string.Empty : settingsManager.ModelsDirectory
)
{ {
Title = g.Key.GetDescription() ?? g.Key.ToString() Title = g.Key.GetDescription() ?? g.Key.ToString()
} }
@ -149,7 +153,7 @@ public partial class HuggingFacePageViewModel : TabViewModelBase
var sharedFolderType = viewModel.Item.ModelCategory.ConvertTo<SharedFolderType>(); var sharedFolderType = viewModel.Item.ModelCategory.ConvertTo<SharedFolderType>();
var downloadPath = new FilePath( var downloadPath = new FilePath(
Path.Combine( Path.Combine(
settingsManager.ModelsDirectory, Design.IsDesignMode ? string.Empty : settingsManager.ModelsDirectory,
sharedFolderType.ToString(), sharedFolderType.ToString(),
viewModel.Item.Subfolder ?? string.Empty, viewModel.Item.Subfolder ?? string.Empty,
file file

10
StabilityMatrix.Avalonia/ViewModels/HuggingFacePage/CategoryViewModel.cs

@ -15,7 +15,8 @@ public partial class CategoryViewModel : ViewModelBase
private IObservableCollection<HuggingfaceItemViewModel> items = private IObservableCollection<HuggingfaceItemViewModel> items =
new ObservableCollectionExtended<HuggingfaceItemViewModel>(); new ObservableCollectionExtended<HuggingfaceItemViewModel>();
public SourceCache<HuggingfaceItem, string> ItemsCache { get; } = new(i => i.RepositoryPath + i.ModelName); public SourceCache<HuggingfaceItem, string> ItemsCache { get; } =
new(i => i.RepositoryPath + i.ModelName);
[ObservableProperty] [ObservableProperty]
private string? title; private string? title;
@ -26,12 +27,12 @@ public partial class CategoryViewModel : ViewModelBase
[ObservableProperty] [ObservableProperty]
private int numSelected; private int numSelected;
public CategoryViewModel(IEnumerable<HuggingfaceItem> items) public CategoryViewModel(IEnumerable<HuggingfaceItem> items, string modelsDir)
{ {
ItemsCache ItemsCache
.Connect() .Connect()
.DeferUntilLoaded() .DeferUntilLoaded()
.Transform(i => new HuggingfaceItemViewModel { Item = i }) .Transform(i => new HuggingfaceItemViewModel { Item = i, ModelsDir = modelsDir })
.Bind(Items) .Bind(Items)
.WhenPropertyChanged(p => p.IsSelected) .WhenPropertyChanged(p => p.IsSelected)
.Subscribe(_ => NumSelected = Items.Count(i => i.IsSelected)); .Subscribe(_ => NumSelected = Items.Count(i => i.IsSelected));
@ -46,6 +47,9 @@ public partial class CategoryViewModel : ViewModelBase
foreach (var item in Items) foreach (var item in Items)
{ {
if (item.Exists)
continue;
item.IsSelected = value; item.IsSelected = value;
} }
} }

17
StabilityMatrix.Avalonia/ViewModels/HuggingFacePage/HuggingfaceItemViewModel.cs

@ -1,7 +1,10 @@
using CommunityToolkit.Mvvm.ComponentModel; using System.IO;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using StabilityMatrix.Avalonia.Models.HuggingFace; using StabilityMatrix.Avalonia.Models.HuggingFace;
using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Models;
namespace StabilityMatrix.Avalonia.ViewModels.HuggingFacePage; namespace StabilityMatrix.Avalonia.ViewModels.HuggingFacePage;
@ -17,6 +20,18 @@ public partial class HuggingfaceItemViewModel : ViewModelBase
$"https://huggingface.co/{Item.RepositoryPath}/blob/main/{Item.LicensePath ?? "README.md"}"; $"https://huggingface.co/{Item.RepositoryPath}/blob/main/{Item.LicensePath ?? "README.md"}";
public string RepoUrl => $"https://huggingface.co/{Item.RepositoryPath}"; public string RepoUrl => $"https://huggingface.co/{Item.RepositoryPath}";
public required string? ModelsDir { get; init; }
public bool Exists =>
File.Exists(
Path.Combine(
ModelsDir,
Item.ModelCategory.ConvertTo<SharedFolderType>().ToString(),
Item.Subfolder ?? string.Empty,
Item.Files[0]
)
);
[RelayCommand] [RelayCommand]
private void ToggleSelected() private void ToggleSelected()
{ {

1
StabilityMatrix.Avalonia/Views/HuggingFacePage.axaml

@ -102,6 +102,7 @@
<ItemsRepeater.ItemTemplate> <ItemsRepeater.ItemTemplate>
<DataTemplate DataType="{x:Type huggingFacePage:HuggingfaceItemViewModel}"> <DataTemplate DataType="{x:Type huggingFacePage:HuggingfaceItemViewModel}">
<Button <Button
IsEnabled="{Binding !Exists}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
Command="{Binding ToggleSelectedCommand}" Command="{Binding ToggleSelectedCommand}"

Loading…
Cancel
Save