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
- Search box on Checkpoints page now searches tags and trigger words
- 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
- 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

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

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

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

@ -15,7 +15,8 @@ public partial class CategoryViewModel : ViewModelBase
private IObservableCollection<HuggingfaceItemViewModel> items =
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]
private string? title;
@ -26,12 +27,12 @@ public partial class CategoryViewModel : ViewModelBase
[ObservableProperty]
private int numSelected;
public CategoryViewModel(IEnumerable<HuggingfaceItem> items)
public CategoryViewModel(IEnumerable<HuggingfaceItem> items, string modelsDir)
{
ItemsCache
.Connect()
.DeferUntilLoaded()
.Transform(i => new HuggingfaceItemViewModel { Item = i })
.Transform(i => new HuggingfaceItemViewModel { Item = i, ModelsDir = modelsDir })
.Bind(Items)
.WhenPropertyChanged(p => p.IsSelected)
.Subscribe(_ => NumSelected = Items.Count(i => i.IsSelected));
@ -46,6 +47,9 @@ public partial class CategoryViewModel : ViewModelBase
foreach (var item in Items)
{
if (item.Exists)
continue;
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 StabilityMatrix.Avalonia.Models.HuggingFace;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Models;
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"}";
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]
private void ToggleSelected()
{

1
StabilityMatrix.Avalonia/Views/HuggingFacePage.axaml

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

Loading…
Cancel
Save