Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 225e185

Browse files
committed
Simplify ModelTemplate website and repository metadata
1 parent 5ad13e2 commit 225e185

File tree

5 files changed

+33
-20
lines changed

5 files changed

+33
-20
lines changed

OnnxStack.UI/Dialogs/UpdateModelMetadataDialog.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
</StackPanel>
105105
<StackPanel Margin="0,0,4,0" >
106106
<TextBlock Text="Repository" />
107-
<TextBox Text="{Binding RepositoryClone}" />
107+
<TextBox Text="{Binding Repository}" />
108108
</StackPanel>
109109
</DockPanel>
110110
<TextBlock Text="Direct Download" FontSize="15" FontWeight="DemiBold" Margin="0,15,0,0"/>

OnnxStack.UI/Dialogs/UpdateModelMetadataDialog.xaml.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ public string IconImage
8080
set { _iconImage = value; NotifyPropertyChanged(); }
8181
}
8282

83-
private string _repositoryClone;
83+
private string _repository;
8484

85-
public string RepositoryClone
85+
public string Repository
8686
{
87-
get { return _repositoryClone; }
88-
set { _repositoryClone = value; NotifyPropertyChanged(); }
87+
get { return _repository; }
88+
set { _repository = value; NotifyPropertyChanged(); }
8989
}
9090

9191
private string _repositoryBranch;
@@ -105,15 +105,13 @@ public bool ShowDialog(ModelTemplateViewModel modelTemplate)
105105
{
106106
_modelTemplate = modelTemplate;
107107

108-
Website = _modelTemplate.Repository;
108+
Website = _modelTemplate.Website;
109109
Author = _modelTemplate.Author;
110110
Description = _modelTemplate.Description;
111111
IconImage = _modelTemplate.ImageIcon;
112-
113-
var repository = _modelTemplate.RepositoryClone?.Split("-b", StringSplitOptions.TrimEntries);
114-
RepositoryClone = repository?.FirstOrDefault();
115-
RepositoryBranch = repository?.LastOrDefault();
116-
112+
Repository = _modelTemplate.Repository;
113+
RepositoryBranch = _modelTemplate.RepositoryBranch;
114+
117115
for (int i = 0; i < 4; i++)
118116
{
119117
PreviewImages.Add(_modelTemplate.PreviewImages?.ElementAtOrDefault(i));
@@ -129,13 +127,12 @@ public bool ShowDialog(ModelTemplateViewModel modelTemplate)
129127
private Task Save()
130128
{
131129
// validate links;
132-
_modelTemplate.Repository = Website;
130+
_modelTemplate.Website = Website;
133131
_modelTemplate.Author = Author;
134132
_modelTemplate.ImageIcon = IconImage;
135133
_modelTemplate.Description = Description;
136-
_modelTemplate.RepositoryClone = string.IsNullOrEmpty(_repositoryBranch)
137-
? RepositoryClone
138-
: $"{_repositoryClone} -b {_repositoryBranch}";
134+
_modelTemplate.Repository = Repository;
135+
_modelTemplate.RepositoryBranch = RepositoryBranch;
139136
_modelTemplate.PreviewImages = PreviewImages.Where(x => !string.IsNullOrEmpty(x)).ToList();
140137
_modelTemplate.RepositoryFiles = RepositoryFiles.Where(x => !string.IsNullOrEmpty(x)).ToList();
141138

OnnxStack.UI/Dialogs/ViewModelMetadataDialog.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</StackPanel>
3838
<StackPanel Margin="0,0,4,0" >
3939
<TextBlock Text="Website" FontWeight="DemiBold" Margin="0,15,0,0" Opacity=".7"/>
40-
<TextBlock Text="{Binding ModelTemplate.Repository, TargetNullValue=Unknown}" />
40+
<TextBlock Text="{Binding ModelTemplate.Website, TargetNullValue=Unknown}" />
4141
</StackPanel>
4242
</DockPanel>
4343

@@ -51,7 +51,7 @@
5151

5252
<StackPanel>
5353
<TextBlock Text="Repository Clone" FontWeight="DemiBold" Margin="0,15,0,0" Opacity=".7"/>
54-
<TextBlock Text="{Binding ModelTemplate.RepositoryClone, TargetNullValue=Unknown}" />
54+
<TextBlock Text="{Binding ModelTemplate.Repository, TargetNullValue=Unknown}" />
5555
</StackPanel>
5656

5757
<TextBlock Text="Direct Download Files" FontWeight="DemiBold" Margin="0,15,0,0" Opacity=".7"/>

OnnxStack.UI/Views/ModelSettingsView.xaml.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,18 +810,31 @@ public string Description
810810
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
811811
public StableDiffusionModelTemplate StableDiffusionTemplate { get; set; }
812812

813+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
814+
public string Website { get; set; }
815+
813816
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
814817
public string Repository { get; set; }
815818

816819
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
817-
public string RepositoryClone { get; set; }
820+
public string RepositoryBranch { get; set; }
818821

819822
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
820823
public List<string> RepositoryFiles { get; set; }
821824

822825
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
823826
public List<string> PreviewImages { get; set; }
824827

828+
[JsonIgnore]
829+
public string RepositoryClone
830+
{
831+
get
832+
{
833+
return string.IsNullOrEmpty(RepositoryBranch)
834+
? Repository
835+
: $"{Repository} -b {RepositoryBranch}";
836+
}
837+
}
825838

826839
[JsonIgnore]
827840
public bool IsInstalled
@@ -859,14 +872,16 @@ public string ErrorMessage
859872
}
860873

861874
[JsonIgnore]
862-
public bool IsRepositoryCloneEnabled => !string.IsNullOrEmpty(RepositoryClone);
875+
public bool IsRepositoryCloneEnabled => !string.IsNullOrEmpty(Repository);
863876

864877
[JsonIgnore]
865878
public bool IsRepositoryDownloadEnabled => !RepositoryFiles.IsNullOrEmpty();
866879

867880
[JsonIgnore]
868881
public CancellationTokenSource CancellationTokenSource { get; set; }
869882

883+
884+
870885
#region INotifyPropertyChanged
871886
public event PropertyChangedEventHandler PropertyChanged;
872887

OnnxStack.UI/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"DefaultIntraOpNumThreads": 0,
4545
"DefaultExecutionMode": "ORT_SEQUENTIAL",
4646
"DefaultExecutionProvider": "DirectML",
47+
4748
"Templates": [
4849
{
4950
"Name": "StableDiffusion",
@@ -207,7 +208,7 @@
207208
]
208209
},
209210
"Repository": "https://huggingface.co/runwayml/stable-diffusion-v1-5",
210-
"RepositoryClone": "https://huggingface.co/runwayml/stable-diffusion-v1-5 -b onnx",
211+
"RepositoryBranch": "onnx",
211212
"RepositoryFiles": [
212213
"https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/onnx/unet/model.onnx",
213214
"https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/onnx/unet/weights.pb",

0 commit comments

Comments
 (0)