mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat: facial recognition (#2180)
This commit is contained in:
9
server/libs/domain/test/face.repository.mock.ts
Normal file
9
server/libs/domain/test/face.repository.mock.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { IFaceRepository } from '../src';
|
||||
|
||||
export const newFaceRepositoryMock = (): jest.Mocked<IFaceRepository> => {
|
||||
return {
|
||||
getAll: jest.fn(),
|
||||
getByIds: jest.fn(),
|
||||
create: jest.fn(),
|
||||
};
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
APIKeyEntity,
|
||||
AssetEntity,
|
||||
AssetType,
|
||||
PersonEntity,
|
||||
PartnerEntity,
|
||||
SharedLinkEntity,
|
||||
SharedLinkType,
|
||||
@@ -10,6 +11,7 @@ import {
|
||||
TranscodePreset,
|
||||
UserEntity,
|
||||
UserTokenEntity,
|
||||
AssetFaceEntity,
|
||||
} from '@app/infra/entities';
|
||||
import {
|
||||
AlbumResponseDto,
|
||||
@@ -142,6 +144,7 @@ export const assetEntityStub = {
|
||||
livePhotoVideoId: null,
|
||||
tags: [],
|
||||
sharedLinks: [],
|
||||
faces: [],
|
||||
}),
|
||||
image: Object.freeze<AssetEntity>({
|
||||
id: 'asset-id',
|
||||
@@ -168,6 +171,7 @@ export const assetEntityStub = {
|
||||
tags: [],
|
||||
sharedLinks: [],
|
||||
originalFileName: 'asset-id.ext',
|
||||
faces: [],
|
||||
}),
|
||||
video: Object.freeze<AssetEntity>({
|
||||
id: 'asset-id',
|
||||
@@ -194,6 +198,7 @@ export const assetEntityStub = {
|
||||
livePhotoVideoId: null,
|
||||
tags: [],
|
||||
sharedLinks: [],
|
||||
faces: [],
|
||||
}),
|
||||
livePhotoMotionAsset: Object.freeze({
|
||||
id: 'live-photo-motion-asset',
|
||||
@@ -372,6 +377,7 @@ const assetResponse: AssetResponseDto = {
|
||||
exifInfo: assetInfo,
|
||||
livePhotoVideoId: null,
|
||||
tags: [],
|
||||
people: [],
|
||||
};
|
||||
|
||||
const albumResponse: AlbumResponseDto = {
|
||||
@@ -655,6 +661,7 @@ export const sharedLinkStub = {
|
||||
},
|
||||
tags: [],
|
||||
sharedLinks: [],
|
||||
faces: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -729,6 +736,7 @@ export const searchStub = {
|
||||
page: 1,
|
||||
items: [],
|
||||
facets: [],
|
||||
distances: [],
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -826,6 +834,39 @@ export const probeStub = {
|
||||
}),
|
||||
};
|
||||
|
||||
export const personStub = {
|
||||
noName: Object.freeze<PersonEntity>({
|
||||
id: 'person-1',
|
||||
createdAt: new Date('2021-01-01'),
|
||||
updatedAt: new Date('2021-01-01'),
|
||||
ownerId: userEntityStub.admin.id,
|
||||
owner: userEntityStub.admin,
|
||||
name: '',
|
||||
thumbnailPath: '/path/to/thumbnail',
|
||||
faces: [],
|
||||
}),
|
||||
withName: Object.freeze<PersonEntity>({
|
||||
id: 'person-1',
|
||||
createdAt: new Date('2021-01-01'),
|
||||
updatedAt: new Date('2021-01-01'),
|
||||
ownerId: userEntityStub.admin.id,
|
||||
owner: userEntityStub.admin,
|
||||
name: 'Person 1',
|
||||
thumbnailPath: '/path/to/thumbnail',
|
||||
faces: [],
|
||||
}),
|
||||
noThumbnail: Object.freeze<PersonEntity>({
|
||||
id: 'person-1',
|
||||
createdAt: new Date('2021-01-01'),
|
||||
updatedAt: new Date('2021-01-01'),
|
||||
ownerId: userEntityStub.admin.id,
|
||||
owner: userEntityStub.admin,
|
||||
name: '',
|
||||
thumbnailPath: '',
|
||||
faces: [],
|
||||
}),
|
||||
};
|
||||
|
||||
export const partnerStub = {
|
||||
adminToUser1: Object.freeze<PartnerEntity>({
|
||||
createdAt: new Date('2023-02-23T05:06:29.716Z'),
|
||||
@@ -844,3 +885,13 @@ export const partnerStub = {
|
||||
sharedWith: userEntityStub.admin,
|
||||
}),
|
||||
};
|
||||
|
||||
export const faceStub = {
|
||||
face1: Object.freeze<AssetFaceEntity>({
|
||||
assetId: assetEntityStub.image.id,
|
||||
asset: assetEntityStub.image,
|
||||
personId: personStub.withName.id,
|
||||
person: personStub.withName,
|
||||
embedding: [1, 2, 3, 4],
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -3,11 +3,13 @@ export * from './api-key.repository.mock';
|
||||
export * from './asset.repository.mock';
|
||||
export * from './communication.repository.mock';
|
||||
export * from './crypto.repository.mock';
|
||||
export * from './face.repository.mock';
|
||||
export * from './fixtures';
|
||||
export * from './job.repository.mock';
|
||||
export * from './machine-learning.repository.mock';
|
||||
export * from './media.repository.mock';
|
||||
export * from './partner.repository.mock';
|
||||
export * from './person.repository.mock';
|
||||
export * from './search.repository.mock';
|
||||
export * from './shared-link.repository.mock';
|
||||
export * from './smart-info.repository.mock';
|
||||
|
||||
@@ -6,5 +6,6 @@ export const newMachineLearningRepositoryMock = (): jest.Mocked<IMachineLearning
|
||||
detectObjects: jest.fn(),
|
||||
encodeImage: jest.fn(),
|
||||
encodeText: jest.fn(),
|
||||
detectFaces: jest.fn(),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ export const newMediaRepositoryMock = (): jest.Mocked<IMediaRepository> => {
|
||||
extractThumbnailFromExif: jest.fn(),
|
||||
extractVideoThumbnail: jest.fn(),
|
||||
resize: jest.fn(),
|
||||
crop: jest.fn(),
|
||||
probe: jest.fn(),
|
||||
transcode: jest.fn(),
|
||||
};
|
||||
|
||||
15
server/libs/domain/test/person.repository.mock.ts
Normal file
15
server/libs/domain/test/person.repository.mock.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { IPersonRepository } from '../src';
|
||||
|
||||
export const newPersonRepositoryMock = (): jest.Mocked<IPersonRepository> => {
|
||||
return {
|
||||
getById: jest.fn(),
|
||||
getAll: jest.fn(),
|
||||
getAssets: jest.fn(),
|
||||
getAllWithoutFaces: jest.fn(),
|
||||
|
||||
create: jest.fn(),
|
||||
update: jest.fn(),
|
||||
deleteAll: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
};
|
||||
};
|
||||
@@ -6,11 +6,15 @@ export const newSearchRepositoryMock = (): jest.Mocked<ISearchRepository> => {
|
||||
checkMigrationStatus: jest.fn(),
|
||||
importAssets: jest.fn(),
|
||||
importAlbums: jest.fn(),
|
||||
importFaces: jest.fn(),
|
||||
deleteAlbums: jest.fn(),
|
||||
deleteAssets: jest.fn(),
|
||||
deleteFaces: jest.fn(),
|
||||
deleteAllFaces: jest.fn(),
|
||||
searchAssets: jest.fn(),
|
||||
searchAlbums: jest.fn(),
|
||||
vectorSearch: jest.fn(),
|
||||
explore: jest.fn(),
|
||||
searchFaces: jest.fn(),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user