feat: Implement face clustering management service and API

This commit is contained in:
shiyu
2025-06-16 20:07:39 +08:00
parent cfda1ed930
commit 429ce92cdb
18 changed files with 1949 additions and 14 deletions

View File

@@ -6,19 +6,21 @@ namespace Foxel.Models.DataBase;
public class Face : BaseModel
{
public float[]? Embedding { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int W { get; set; }
public int H { get; set; }
[Range(0.0, 1.0)]
public double FaceConfidence { get; set; }
public int PictureId { get; set; }
[StringLength(255)]
public string? PersonName { get; set; }
[ForeignKey("PictureId")]
public Picture Picture { get; set; } = null!;
public int? ClusterId { get; set; }
[ForeignKey("ClusterId")]
public FaceCluster? Cluster { get; set; }
}

View File

@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;
namespace Foxel.Models.DataBase;
public class FaceCluster : BaseModel
{
[StringLength(255)]
public string Name { get; set; } = string.Empty;
[StringLength(1024)]
public string? Description { get; set; }
/// <summary>
/// 用户设置的人物名称
/// </summary>
[StringLength(255)]
public string? PersonName { get; set; }
/// <summary>
/// 最后更新时间
/// </summary>
public DateTime LastUpdatedAt { get; set; }
public ICollection<Face>? Faces { get; set; }
}

View File

@@ -0,0 +1,13 @@
namespace Foxel.Models.Response.Face;
public record FaceClusterResponse
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? PersonName { get; set; }
public string? Description { get; set; }
public int FaceCount { get; set; }
public string? ThumbnailPath { get; set; }
public DateTime LastUpdatedAt { get; set; }
public DateTime CreatedAt { get; set; }
}

View File

@@ -1,4 +1,5 @@
using Foxel.Models.DataBase;
using Foxel.Models.Response.Face;
namespace Foxel.Models.Response.Picture;
@@ -27,5 +28,5 @@ public record PictureResponse
public string? AlbumName { get; set; }
public PermissionType Permission { get; set; } = PermissionType.Public;
public string? StorageModeName { get; set; }
public List<FaceResponse>? Faces { get; set; }
public List<FaceResponse>? Faces { get; set; }
}