Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions StabilityMatrix.Core/Helper/RemoteModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
[
new()
{
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8m.pt"),
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/face_yolov8m.pt"),
HashSha256 = "f02b8a23e6f12bd2c1b1f6714f66f984c728fa41ed749d033e7d6dea511ef70c",
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
Author = "Bingsu",
Expand All @@ -212,7 +212,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
},
new()
{
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt"),
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/hand_yolov8s.pt"),
HashSha256 = "5c4faf8d17286ace2c3d3346c6d0d4a0c8d62404955263a7ae95c1dd7eb877af",
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
Author = "Bingsu",
Expand All @@ -225,7 +225,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
},
new()
{
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8m-seg.pt"),
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/person_yolov8m-seg.pt"),
HashSha256 = "9d881ec50b831f546e37977081b18f4e3bf65664aec163f97a311b0955499795",
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
Author = "Bingsu",
Expand All @@ -238,7 +238,7 @@ private static RemoteResource ControlNetCommon(string path, string sha256)
},
new()
{
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8s-seg.pt"),
Url = new Uri("https://huggingface.co/Bingsu/adetailer/resolve/b0a075fd35454c86bb453a1ca06b29ffee704c20/person_yolov8s-seg.pt"),
HashSha256 = "b5684835e79fd8b805459e0f7a0f9daa437e421cb4a214fff45ec4ac61767ef9",
InfoUrl = new Uri("https://huggingface.co/Bingsu/adetailer"),
Author = "Bingsu",
Expand Down
50 changes: 50 additions & 0 deletions StabilityMatrix.Tests/Core/RemoteModelsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Reflection;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models;

namespace StabilityMatrix.Tests.Core;

[TestClass]
public class RemoteModelsTests
{
[TestMethod]
public void ExecutableHuggingFaceModelsUsePinnedRevisions()
{
var executableExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
".bin",
".ckpt",
".pt",
".pth",
};

var resources = typeof(RemoteModels)
.GetProperties(BindingFlags.Public | BindingFlags.Static)
.Select(property => property.GetValue(null))
.SelectMany(
value =>
value switch
{
IEnumerable<RemoteResource> remoteResources => remoteResources,
IEnumerable<HybridModelFile> hybridModels => hybridModels
.Where(model => model.DownloadableResource.HasValue)
.Select(model => model.DownloadableResource!.Value),
HybridModelFile { DownloadableResource: { } resource } => [resource],
_ => [],
}
);

var unpinnedModels = resources
.Where(resource => resource.Url.Host == "huggingface.co")
.Where(resource => executableExtensions.Contains(Path.GetExtension(resource.Url.AbsolutePath)))
.Where(resource => resource.Url.AbsolutePath.Contains("/resolve/main/", StringComparison.Ordinal))
.Select(resource => resource.Url)
.ToArray();

Assert.AreEqual(
0,
unpinnedModels.Length,
$"Executable Hugging Face model URLs must use pinned revisions: {string.Join(", ", unpinnedModels.Select(url => url.AbsoluteUri))}"
);
}
Comment thread
ungrav marked this conversation as resolved.
}
Loading