Skip to content

Commit 922a68a

Browse files
authored
Merge pull request #903 from ionite34/backport/main/pr-902
[dev to main] backport: Fix package images (902)
2 parents 623601e + f92ee13 commit 922a68a

File tree

11 files changed

+111
-25
lines changed

11 files changed

+111
-25
lines changed

Directory.Build.props

+6
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
<PropertyGroup>
33
<AvaloniaVersion>11.1.4</AvaloniaVersion>
44
</PropertyGroup>
5+
6+
<PropertyGroup>
7+
<!--Some bug with SDK 8.0.403
8+
https://github.com/dotnet/sdk/issues/44026-->
9+
<NoWarn>$(NoWarn);CsWinRT1028</NoWarn>
10+
</PropertyGroup>
511
</Project>

StabilityMatrix.Core/Models/Packages/ComfyUI.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ IPrerequisiteHelper prerequisiteHelper
3737
public override string Blurb => "A powerful and modular stable diffusion GUI and backend";
3838
public override string LaunchCommand => "main.py";
3939

40-
public override Uri PreviewImageUri =>
41-
new("https://github.com/comfyanonymous/ComfyUI/raw/master/comfyui_screenshot.png");
40+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/comfyui/preview.webp");
4241
public override bool ShouldIgnoreReleases => true;
4342
public override bool IsInferenceCompatible => true;
4443
public override string OutputFolderName => "output";

StabilityMatrix.Core/Models/Packages/KohyaSs.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ IPyRunner runner
2727
public override string LicenseUrl => "https://github.com/bmaltais/kohya_ss/blob/master/LICENSE.md";
2828
public override string LaunchCommand => "kohya_gui.py";
2929

30-
public override Uri PreviewImageUri =>
31-
new(
32-
"https://camo.githubusercontent.com/5154eea62c113d5c04393e51a0d0f76ef25a723aad29d256dcc85ead1961cd41/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f6b35696d713031757655592f302e6a7067"
33-
);
30+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/kohyass/preview.webp");
3431
public override string OutputFolderName => string.Empty;
3532

3633
public override bool IsCompatible => HardwareHelper.HasNvidiaGpu();

StabilityMatrix.Core/Models/Packages/Mashb1tFooocus.cs

-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ IPrerequisiteHelper prerequisiteHelper
2323

2424
public override string LicenseUrl => "https://github.com/mashb1t/Fooocus/blob/main/LICENSE";
2525

26-
public override Uri PreviewImageUri =>
27-
new("https://github.com/lllyasviel/Fooocus/assets/19834515/483fb86d-c9a2-4c20-997c-46dafc124f25");
28-
2926
public override bool ShouldIgnoreReleases => false;
3027
}

StabilityMatrix.Core/Models/Packages/Reforge.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ IPrerequisiteHelper prerequisiteHelper
2121
"Stable Diffusion WebUI reForge is a platform on top of Stable Diffusion WebUI (based on Gradio) to make development easier, optimize resource management, speed up inference, and study experimental features.";
2222
public override string LicenseUrl =>
2323
"https://github.com/Panchovix/stable-diffusion-webui-reForge/blob/main/LICENSE.txt";
24-
public override Uri PreviewImageUri =>
25-
new(
26-
"https://github.com/lllyasviel/stable-diffusion-webui-forge/assets/19834515/de1a2d05-344a-44d7-bab8-9ecc0a58a8d3"
27-
);
24+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/reforge/preview.webp");
2825

2926
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.ReallyRecommended;
3027
}

StabilityMatrix.Core/Models/Packages/SDWebForge.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ IPrerequisiteHelper prerequisiteHelper
2929
public override string LicenseUrl =>
3030
"https://github.com/lllyasviel/stable-diffusion-webui-forge/blob/main/LICENSE.txt";
3131

32-
public override Uri PreviewImageUri =>
33-
new(
34-
"https://github.com/lllyasviel/stable-diffusion-webui-forge/assets/19834515/ca5e05ed-bd86-4ced-8662-f41034648e8c"
35-
);
32+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/sdwebforge/preview.webp");
3633

3734
public override string MainBranch => "main";
3835
public override bool ShouldIgnoreReleases => true;

StabilityMatrix.Core/Models/Packages/SimpleSDXL.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ IPrerequisiteHelper prerequisiteHelper
2424
public override string Blurb =>
2525
"Enhanced version of Fooocus for SDXL, more suitable for Chinese and Cloud. Supports Flux.";
2626
public override string LicenseUrl => "https://github.com/metercai/SimpleSDXL/blob/SimpleSDXL/LICENSE";
27-
public override Uri PreviewImageUri =>
28-
new("https://github.com/user-attachments/assets/98715a4d-9f4a-4846-ae62-eb8d69793d31");
27+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/simplesdxl/preview.webp");
2928
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Expert;
3029
public override IEnumerable<SharedFolderMethod> AvailableSharedFolderMethods =>
3130
[SharedFolderMethod.Configuration, SharedFolderMethod.Symlink, SharedFolderMethod.None];

StabilityMatrix.Core/Models/Packages/VladAutomatic.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ IPrerequisiteHelper prerequisiteHelper
3636
public override string Blurb => "Stable Diffusion implementation with advanced features and modern UI";
3737
public override string LaunchCommand => "launch.py";
3838

39-
public override Uri PreviewImageUri =>
40-
new("https://github.com/vladmandic/automatic/raw/master/html/screenshot-modernui.jpg");
39+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/vladautomatic/preview.webp");
4140
public override bool ShouldIgnoreReleases => true;
4241

4342
public override SharedFolderMethod RecommendedSharedFolderMethod => SharedFolderMethod.Symlink;

StabilityMatrix.Core/Models/Packages/VoltaML.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ IPrerequisiteHelper prerequisiteHelper
2626
public override string Blurb => "Fast Stable Diffusion with support for AITemplate";
2727
public override string LaunchCommand => "main.py";
2828

29-
public override Uri PreviewImageUri =>
30-
new(
31-
"https://github.com/LykosAI/StabilityMatrix/assets/13956642/d9a908ed-5665-41a5-a380-98458f4679a8"
32-
);
29+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/voltaml/preview.webp");
3330

3431
public override PackageDifficulty InstallerSortOrder => PackageDifficulty.Simple;
3532

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Microsoft.Extensions.DependencyInjection.Extensions;
3+
using NSubstitute;
4+
using StabilityMatrix.Core.Helper;
5+
using StabilityMatrix.Core.Helper.Cache;
6+
using StabilityMatrix.Core.Models.Packages;
7+
using StabilityMatrix.Core.Python;
8+
using StabilityMatrix.Core.Services;
9+
10+
namespace StabilityMatrix.Tests.Models.Packages;
11+
12+
public static class PackageHelper
13+
{
14+
/// <summary>
15+
/// Get all BasePackage implementations in the assembly.
16+
/// </summary>
17+
public static IEnumerable<BasePackage> GetPackages()
18+
{
19+
var services = new ServiceCollection();
20+
services
21+
.AddSingleton(Substitute.For<IGithubApiCache>())
22+
.AddSingleton(Substitute.For<ISettingsManager>())
23+
.AddSingleton(Substitute.For<IDownloadService>())
24+
.AddSingleton(Substitute.For<IPyRunner>())
25+
.AddSingleton(Substitute.For<IPrerequisiteHelper>());
26+
27+
var assembly = typeof(BasePackage).Assembly;
28+
var packageTypes = assembly
29+
.GetTypes()
30+
.Where(t => t.IsSubclassOf(typeof(BasePackage)) && !t.IsAbstract)
31+
.Where(t => t != typeof(DankDiffusion) && t != typeof(UnknownPackage))
32+
.ToList();
33+
34+
// Register all package types
35+
services.TryAddEnumerable(
36+
packageTypes.Select(t => ServiceDescriptor.Singleton(typeof(BasePackage), t))
37+
);
38+
39+
var serviceProvider = services.BuildServiceProvider();
40+
return serviceProvider.GetServices<BasePackage>();
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Net.Http.Headers;
2+
using StabilityMatrix.Core.Models.Packages;
3+
4+
namespace StabilityMatrix.Tests.Models.Packages;
5+
6+
/// <summary>
7+
/// Tests that URL links on Packages should be valid. Requires internet connection.
8+
/// </summary>
9+
[TestClass]
10+
public sealed class PackageLinkTests
11+
{
12+
private static HttpClient HttpClient { get; } =
13+
new() { DefaultRequestHeaders = { { "User-Agent", "StabilityMatrix/2.0" } } };
14+
15+
private static IEnumerable<object[]> PackagesData =>
16+
PackageHelper.GetPackages().Select(p => new object[] { p });
17+
18+
[TestMethod]
19+
[DynamicData(nameof(PackagesData))]
20+
public async Task TestPreviewImageUri(BasePackage package)
21+
{
22+
var imageUri = package.PreviewImageUri;
23+
24+
// Test http head is successful
25+
var response = await HttpClient.SendAsync(new HttpRequestMessage(HttpMethod.Head, imageUri));
26+
27+
Assert.IsTrue(
28+
response.IsSuccessStatusCode,
29+
"Failed to get PreviewImageUri at {0}: {1}",
30+
imageUri,
31+
response
32+
);
33+
}
34+
35+
[TestMethod]
36+
[DynamicData(nameof(PackagesData))]
37+
public async Task TestLicenseUrl(BasePackage package)
38+
{
39+
if (string.IsNullOrEmpty(package.LicenseUrl))
40+
{
41+
Assert.Inconclusive();
42+
}
43+
44+
var licenseUri = package.LicenseUrl;
45+
46+
// Test http head is successful
47+
var response = await HttpClient.SendAsync(new HttpRequestMessage(HttpMethod.Head, licenseUri));
48+
49+
Assert.IsTrue(
50+
response.IsSuccessStatusCode,
51+
"Failed to get LicenseUrl at {0}: {1}",
52+
licenseUri,
53+
response
54+
);
55+
}
56+
}

0 commit comments

Comments
 (0)