mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
chore(server,ml): remove object detection job and endpoint (#2627)
* removed object detection job * removed object detection endpoint
This commit is contained in:
@@ -21,7 +21,6 @@ export interface DetectFaceResult {
|
||||
|
||||
export interface IMachineLearningRepository {
|
||||
classifyImage(input: MachineLearningInput): Promise<string[]>;
|
||||
detectObjects(input: MachineLearningInput): Promise<string[]>;
|
||||
encodeImage(input: MachineLearningInput): Promise<number[]>;
|
||||
encodeText(input: string): Promise<number[]>;
|
||||
detectFaces(input: MachineLearningInput): Promise<DetectFaceResult[]>;
|
||||
|
||||
@@ -49,7 +49,6 @@ describe(SmartInfoService.name, () => {
|
||||
|
||||
expect(jobMock.queue.mock.calls).toEqual([
|
||||
[{ name: JobName.CLASSIFY_IMAGE, data: { id: assetEntityStub.image.id } }],
|
||||
[{ name: JobName.DETECT_OBJECTS, data: { id: assetEntityStub.image.id } }],
|
||||
]);
|
||||
expect(assetMock.getWithout).toHaveBeenCalledWith({ skip: 0, take: 1000 }, WithoutProperty.OBJECT_TAGS);
|
||||
});
|
||||
@@ -64,7 +63,6 @@ describe(SmartInfoService.name, () => {
|
||||
|
||||
expect(jobMock.queue.mock.calls).toEqual([
|
||||
[{ name: JobName.CLASSIFY_IMAGE, data: { id: assetEntityStub.image.id } }],
|
||||
[{ name: JobName.DETECT_OBJECTS, data: { id: assetEntityStub.image.id } }],
|
||||
]);
|
||||
expect(assetMock.getAll).toHaveBeenCalled();
|
||||
});
|
||||
@@ -103,39 +101,6 @@ describe(SmartInfoService.name, () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleDetectObjects', () => {
|
||||
it('should skip assets without a resize path', async () => {
|
||||
const asset = { resizePath: '' } as AssetEntity;
|
||||
assetMock.getByIds.mockResolvedValue([asset]);
|
||||
|
||||
await sut.handleDetectObjects({ id: asset.id });
|
||||
|
||||
expect(smartMock.upsert).not.toHaveBeenCalled();
|
||||
expect(machineMock.detectObjects).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should save the returned objects', async () => {
|
||||
machineMock.detectObjects.mockResolvedValue(['obj1', 'obj2', 'obj3']);
|
||||
|
||||
await sut.handleDetectObjects({ id: asset.id });
|
||||
|
||||
expect(machineMock.detectObjects).toHaveBeenCalledWith({ thumbnailPath: 'path/to/resize.ext' });
|
||||
expect(smartMock.upsert).toHaveBeenCalledWith({
|
||||
assetId: 'asset-1',
|
||||
objects: ['obj1', 'obj2', 'obj3'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should no update the smart info if no objects were returned', async () => {
|
||||
machineMock.detectObjects.mockResolvedValue([]);
|
||||
|
||||
await sut.handleDetectObjects({ id: asset.id });
|
||||
|
||||
expect(machineMock.detectObjects).toHaveBeenCalled();
|
||||
expect(smartMock.upsert).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleQueueEncodeClip', () => {
|
||||
it('should queue the assets without clip embeddings', async () => {
|
||||
assetMock.getWithout.mockResolvedValue({
|
||||
|
||||
@@ -27,30 +27,12 @@ export class SmartInfoService {
|
||||
for await (const assets of assetPagination) {
|
||||
for (const asset of assets) {
|
||||
await this.jobRepository.queue({ name: JobName.CLASSIFY_IMAGE, data: { id: asset.id } });
|
||||
await this.jobRepository.queue({ name: JobName.DETECT_OBJECTS, data: { id: asset.id } });
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async handleDetectObjects({ id }: IEntityJob) {
|
||||
const [asset] = await this.assetRepository.getByIds([id]);
|
||||
|
||||
if (!MACHINE_LEARNING_ENABLED || !asset.resizePath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const objects = await this.machineLearning.detectObjects({ thumbnailPath: asset.resizePath });
|
||||
if (objects.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await this.repository.upsert({ assetId: asset.id, objects });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async handleClassifyImage({ id }: IEntityJob) {
|
||||
const [asset] = await this.assetRepository.getByIds([id]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user