Skip to content

Commit 39791e0

Browse files
authored
Merge pull request LykosAI#1097 from ionite34/new-civit-browser
New civit browser
2 parents d4277ce + ce562f1 commit 39791e0

51 files changed

Lines changed: 3282 additions & 302 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
1414
- Added "Select All" button to the Installed Extensions page
1515
- Added experimental ROCm pytorch install for ComfyUI (non-Zluda) on Windows - requires a compatible AMD GPU
1616
### Changed
17+
- Redesigned Civitai model details page
1718
- You can now select release versions when installing ComfyUI
1819
- You can no longer select branches when installing InvokeAI
1920
- Updated InvokeAI install to use pinned torch index from release tag

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
13-
<AvaloniaVersion>11.2.5</AvaloniaVersion>
13+
<AvaloniaVersion>11.3.2</AvaloniaVersion>
1414
</PropertyGroup>
1515

1616
<PropertyGroup>

StabilityMatrix.Avalonia/DesignData/DesignData.cs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using StabilityMatrix.Avalonia.ViewModels.PackageManager;
3030
using StabilityMatrix.Avalonia.ViewModels.Progress;
3131
using StabilityMatrix.Avalonia.ViewModels.Settings;
32+
using StabilityMatrix.Avalonia.Views.Dialogs;
3233
using StabilityMatrix.Core.Api;
3334
using StabilityMatrix.Core.Database;
3435
using StabilityMatrix.Core.Extensions;
@@ -37,6 +38,7 @@
3738
using StabilityMatrix.Core.Helper.Factory;
3839
using StabilityMatrix.Core.Models;
3940
using StabilityMatrix.Core.Models.Api;
41+
using StabilityMatrix.Core.Models.Api.CivitTRPC;
4042
using StabilityMatrix.Core.Models.Api.Comfy;
4143
using StabilityMatrix.Core.Models.Api.OpenArt;
4244
using StabilityMatrix.Core.Models.Api.OpenModelsDb;
@@ -734,6 +736,91 @@ public static UpdateSettingsViewModel UpdateSettingsViewModel
734736
public static CheckpointBrowserViewModel CheckpointBrowserViewModel =>
735737
Services.GetRequiredService<CheckpointBrowserViewModel>();
736738

739+
public static CivitDetailsPageViewModel CivitDetailsPageViewModel =>
740+
DialogFactory.Get<CivitDetailsPageViewModel>(vm =>
741+
{
742+
vm.CivitModel = new CivitModel
743+
{
744+
Name = "BB95 Furry Mix",
745+
Description = "A furry mix of BB95",
746+
Stats = new CivitModelStats
747+
{
748+
Rating = 3.5,
749+
RatingCount = 24,
750+
ThumbsUpCount = 1337,
751+
DownloadCount = 100_000,
752+
},
753+
Tags = ["base model", "furry", "animals", "photorealistic", "highly detailed", "yiff"],
754+
ModelVersions =
755+
[
756+
new CivitModelVersion
757+
{
758+
Name = "v1.2.2-Inpainting",
759+
PublishedAt = DateTimeOffset.Now,
760+
Images =
761+
[
762+
new CivitImage
763+
{
764+
Url =
765+
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/244bc929-9bbc-44b2-8a26-7622a1669f4a/original=true,quality=90/00123-3430906941-1girl,%20hatsune%20miku,%20white%20pupils,%20power%20elements,%20microphone,%20vibrant%20blue%20color%20palette,%20abstract,abstract%20background,%20dreamli.jpeg",
766+
},
767+
new CivitImage
768+
{
769+
Url =
770+
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/aa671302-496f-4dcc-839a-b75a70a7665e/original=true,quality=90/00136-4204868169-1girl,%20solo,%20long%20hair,%20city,%20boots,%20hands%20in%20pockets,%20coat,%20blonde%20hair,%20sky,%20planet,%20night,%20knee%20boots,%20building,%20star%20_(sky_).jpeg",
771+
},
772+
],
773+
Files =
774+
[
775+
new CivitFile
776+
{
777+
Name = "bb95-v100-uwu-reallylongfilename-v1234576802.safetensors",
778+
Type = CivitFileType.Model,
779+
Metadata = new CivitFileMetadata
780+
{
781+
Format = CivitModelFormat.SafeTensor,
782+
Fp = "fp16",
783+
Size = "pruned",
784+
},
785+
},
786+
new CivitFile
787+
{
788+
Name = "bb95-v100-uwu-reallylongfilename-v1234576802-fp32.safetensors",
789+
Type = CivitFileType.Model,
790+
Metadata = new CivitFileMetadata
791+
{
792+
Format = CivitModelFormat.SafeTensor,
793+
Fp = "fp32",
794+
Size = "full",
795+
},
796+
Hashes = new CivitFileHashes
797+
{
798+
BLAKE3 =
799+
"A7383E54F2E4570678B0F18545B2EB8FD95325DA76CCBA8467DBDBD481CF6B99",
800+
SHA256 =
801+
"BDB59BAC77D94AE7A55FF893170F9554C3F349E48A1B73C0C17C0B7C6F4D41A2",
802+
},
803+
},
804+
],
805+
},
806+
new CivitModelVersion { Name = "v1.2.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
807+
new CivitModelVersion { Name = "v1.1.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
808+
new CivitModelVersion { Name = "v1.0.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
809+
new CivitModelVersion { Name = "v0.9.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
810+
new CivitModelVersion { Name = "v0.8.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
811+
new CivitModelVersion { Name = "v0.7.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
812+
new CivitModelVersion { Name = "v0.6.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
813+
new CivitModelVersion { Name = "v0.5.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
814+
new CivitModelVersion { Name = "v0.4.0", PublishedAt = DateTimeOffset.Now.AddDays(-3) },
815+
],
816+
Creator = new CivitCreator
817+
{
818+
Image = "https://gravatar.com/avatar/fe74084ae8a081dc2283f5bde4736756ad?f=y&d=retro",
819+
Username = "creator-1",
820+
},
821+
};
822+
});
823+
737824
public static SelectModelVersionViewModel SelectModelVersionViewModel =>
738825
DialogFactory.Get<SelectModelVersionViewModel>(vm =>
739826
{
@@ -1215,6 +1302,43 @@ public static CompletionList SampleCompletionList
12151302
vm.FileNameText = "TextToImage_00041.png";
12161303
vm.FileSizeText = "2.4 MB";
12171304
vm.ImageSizeText = "1280 x 1792";
1305+
1306+
vm.CivitImageMetadata = new CivitImageGenerationDataResponse
1307+
{
1308+
Metadata = new CivitImageMetadata
1309+
{
1310+
Prompt =
1311+
"closeup photp of a red haired anthro wolf female,\n holding an apple, wearing medieval drees is eating a apple, wolf ears, wolf tail with white tip\n,anthro,furry",
1312+
NegativePrompt = "Bad quality , watermark",
1313+
CfgScale = 2.5d,
1314+
Steps = 30,
1315+
Sampler = "DPM++ SDE",
1316+
Seed = 255842256659122,
1317+
Model = "RatatoskrIllustriousV2.3",
1318+
Height = 1152,
1319+
Width = 768,
1320+
Scheduler = "normal",
1321+
},
1322+
Resources =
1323+
[
1324+
new CivitImageResource
1325+
{
1326+
ModelName = "noobAI XL (NAI-XL) really long name example with even more words",
1327+
ModelId = 1337,
1328+
VersionId = 1234,
1329+
VersionName = "Epsilon-pred 1.1-Version",
1330+
ModelType = "Checkpoint",
1331+
},
1332+
],
1333+
};
1334+
1335+
vm.CivitImageMetadata.OtherMetadata = new Dictionary<string, string>
1336+
{
1337+
["CFG"] = "2.5",
1338+
["Steps"] = "30",
1339+
["Sampler"] = "DPM++ SDE",
1340+
["Seed"] = "255842256659122",
1341+
};
12181342
});
12191343

12201344
public static DownloadResourceViewModel DownloadResourceViewModel =>
@@ -1268,6 +1392,42 @@ public static CompletionList SampleCompletionList
12681392
.ToArray();
12691393
});
12701394

1395+
public static ConfirmBulkDownloadDialogViewModel ConfirmBulkDownloadDialogViewModel =>
1396+
DialogFactory.Get<ConfirmBulkDownloadDialogViewModel>(vm =>
1397+
{
1398+
vm.Model = new CivitModel
1399+
{
1400+
Name = "Test Model",
1401+
ModelVersions = Enumerable
1402+
.Range(1, 64)
1403+
.Select(i => new CivitModelVersion
1404+
{
1405+
Name = $"Version {i}",
1406+
Files =
1407+
[
1408+
new CivitFile
1409+
{
1410+
Name = $"test-file-{i}.safetensors",
1411+
Type = CivitFileType.Model,
1412+
Metadata = new CivitFileMetadata
1413+
{
1414+
Format = CivitModelFormat.SafeTensor,
1415+
Fp = "fp16",
1416+
Size = "pruned",
1417+
},
1418+
SizeKb = new Random().Next(1, 10) * 1024 * 1024,
1419+
},
1420+
],
1421+
})
1422+
.ToList(),
1423+
};
1424+
1425+
vm.FpTypePreference = CivitModelFpType.fp16;
1426+
vm.IncludeVae = true;
1427+
1428+
return vm;
1429+
});
1430+
12711431
public static SponsorshipPromptViewModel SponsorshipPromptViewModel =>
12721432
DialogFactory.Get<SponsorshipPromptViewModel>(vm => { });
12731433

StabilityMatrix.Avalonia/Languages/Resources.Designer.cs

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StabilityMatrix.Avalonia/Languages/Resources.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,4 +1449,16 @@ We prioritize your privacy ([Gen AI Terms](&lt;https://lykos.ai/gen-ai-terms&gt;
14491449
<data name="ValidationError_PackageExists" xml:space="preserve">
14501450
<value>Package named '{0}' already exists</value>
14511451
</data>
1452+
<data name="Label_BulkDownloadStarted" xml:space="preserve">
1453+
<value>Bulk Download Started</value>
1454+
</data>
1455+
<data name="Label_BulkDownloadStartedMessage" xml:space="preserve">
1456+
<value>{0} files have started downloading. Check the Downloads tab for progress.</value>
1457+
</data>
1458+
<data name="Label_DownloadStarted" xml:space="preserve">
1459+
<value>Download Started</value>
1460+
</data>
1461+
<data name="Label_DownloadWillBeSavedToLocation" xml:space="preserve">
1462+
<value>{0} will be saved to {1}</value>
1463+
</data>
14521464
</root>

StabilityMatrix.Avalonia/Models/Inference/FileNameFormat.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public string GetFileName()
3737
return Prefix
3838
+ string.Join(
3939
"",
40-
Parts.Select(
41-
part => part.Match(constant => constant, substitution => substitution.Invoke())
42-
)
40+
Parts.Select(part => part.Match(constant => constant, substitution => substitution.Invoke()))
4341
)
4442
+ Postfix;
4543
}
@@ -69,4 +67,5 @@ public static bool TryParse(
6967
}
7068

7169
public const string DefaultTemplate = "{date}_{time}-{model_name}-{seed}";
70+
public const string DefaultModelBrowserTemplate = "{file_name}";
7271
}

StabilityMatrix.Avalonia/Models/Inference/FileNameFormatProvider.cs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Avalonia.Data;
99
using StabilityMatrix.Core.Extensions;
1010
using StabilityMatrix.Core.Models;
11+
using StabilityMatrix.Core.Models.Api;
1112
using StabilityMatrix.Core.Models.Inference;
1213

1314
namespace StabilityMatrix.Avalonia.Models.Inference;
@@ -20,6 +21,10 @@ public partial class FileNameFormatProvider
2021

2122
public string? ProjectName { get; init; }
2223

24+
public CivitModel? CivitModel { get; init; }
25+
public CivitModelVersion? CivitModelVersion { get; init; }
26+
public CivitFile? CivitFile { get; init; }
27+
2328
private Dictionary<string, Func<string?>>? _substitutions;
2429

2530
public Dictionary<string, Func<string?>> Substitutions =>
@@ -28,7 +33,10 @@ public partial class FileNameFormatProvider
2833
{ "seed", () => GenerationParameters?.Seed.ToString() },
2934
{ "prompt", () => GenerationParameters?.PositivePrompt },
3035
{ "negative_prompt", () => GenerationParameters?.NegativePrompt },
31-
{ "model_name", () => Path.GetFileNameWithoutExtension(GenerationParameters?.ModelName) },
36+
{
37+
"model_name",
38+
() => Path.GetFileNameWithoutExtension(GenerationParameters?.ModelName) ?? CivitModel?.Name
39+
},
3240
{ "model_hash", () => GenerationParameters?.ModelHash },
3341
{ "sampler", () => GenerationParameters?.Sampler },
3442
{ "cfgscale", () => GenerationParameters?.CfgScale.ToString() },
@@ -38,7 +46,15 @@ public partial class FileNameFormatProvider
3846
{ "project_type", () => ProjectType?.GetStringValue() },
3947
{ "project_name", () => ProjectName },
4048
{ "date", () => DateTime.Now.ToString("yyyy-MM-dd") },
41-
{ "time", () => DateTime.Now.ToString("HH-mm-ss") }
49+
{ "time", () => DateTime.Now.ToString("HH-mm-ss") },
50+
{ "author", () => CivitModel?.Creator.Username },
51+
{ "base_model", () => CivitModelVersion?.BaseModel },
52+
{ "file_name", () => Path.GetFileNameWithoutExtension(CivitFile?.Name) },
53+
{ "file_id", () => CivitFile?.Id.ToString() },
54+
{ "model_id", () => CivitModel?.Id.ToString() },
55+
{ "model_version_id", () => CivitModelVersion?.Id.ToString() },
56+
{ "model_version_name", () => CivitModelVersion?.Name },
57+
{ "model_type", () => CivitModel?.Type.ToString() },
4258
};
4359

4460
/// <summary>
@@ -151,7 +167,34 @@ public static FileNameFormatProvider GetSample()
151167
{
152168
GenerationParameters = GenerationParameters.GetSample(),
153169
ProjectType = InferenceProjectType.TextToImage,
154-
ProjectName = "Sample Project"
170+
ProjectName = "Sample Project",
171+
};
172+
}
173+
174+
public static FileNameFormatProvider GetSampleForModelBrowser()
175+
{
176+
return new FileNameFormatProvider
177+
{
178+
CivitModel = new CivitModel
179+
{
180+
Id = 1234,
181+
Name = "Sample Model",
182+
Creator = new CivitCreator { Username = "SampleUser" },
183+
Type = CivitModelType.Checkpoint,
184+
},
185+
CivitModelVersion = new CivitModelVersion
186+
{
187+
Id = 5678,
188+
Name = "v1.0",
189+
BaseModel = "Illustrious",
190+
},
191+
CivitFile = new CivitFile
192+
{
193+
Id = 910,
194+
Name = "sample_file.ckpt",
195+
Type = CivitFileType.Model,
196+
Metadata = new CivitFileMetadata { Size = "pruned" },
197+
},
155198
};
156199
}
157200

StabilityMatrix.Avalonia/Services/IModelImportService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4+
using StabilityMatrix.Avalonia.ViewModels.Inference;
45
using StabilityMatrix.Core.Models;
56
using StabilityMatrix.Core.Models.Api;
67
using StabilityMatrix.Core.Models.Api.OpenModelsDb;
@@ -24,6 +25,8 @@ Task DoImport(
2425
DirectoryPath downloadFolder,
2526
CivitModelVersion? selectedVersion = null,
2627
CivitFile? selectedFile = null,
28+
string? fileNameOverride = null,
29+
SamplerCardViewModel? inferenceDefaults = null,
2730
IProgress<ProgressReport>? progress = null,
2831
Func<Task>? onImportComplete = null,
2932
Func<Task>? onImportCanceled = null,

0 commit comments

Comments
 (0)