1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

fix(server): disable classification by default (#5708)

* disable classification by default

* fixed tests
This commit is contained in:
Mert 2023-12-15 00:34:18 -05:00 committed by GitHub
parent 16f385626e
commit 458257847e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 3 deletions

View File

@ -159,6 +159,9 @@ describe(JobService.name, () => {
it('should handle a start object tagging command', async () => { it('should handle a start object tagging command', async () => {
jobMock.getQueueStatus.mockResolvedValue({ isActive: false, isPaused: false }); jobMock.getQueueStatus.mockResolvedValue({ isActive: false, isPaused: false });
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
await sut.handleCommand(QueueName.OBJECT_TAGGING, { command: JobCommand.START, force: false }); await sut.handleCommand(QueueName.OBJECT_TAGGING, { command: JobCommand.START, force: false });

View File

@ -171,7 +171,7 @@ describe(ServerInfoService.name, () => {
passwordLogin: true, passwordLogin: true,
search: true, search: true,
sidecar: true, sidecar: true,
tagImage: true, tagImage: false,
configFile: false, configFile: false,
trash: true, trash: true,
}); });

View File

@ -48,6 +48,12 @@ describe(SmartInfoService.name, () => {
}); });
describe('handleQueueObjectTagging', () => { describe('handleQueueObjectTagging', () => {
beforeEach(async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
});
it('should do nothing if machine learning is disabled', async () => { it('should do nothing if machine learning is disabled', async () => {
configMock.load.mockResolvedValue([{ key: SystemConfigKey.MACHINE_LEARNING_ENABLED, value: false }]); configMock.load.mockResolvedValue([{ key: SystemConfigKey.MACHINE_LEARNING_ENABLED, value: false }]);
@ -58,6 +64,9 @@ describe(SmartInfoService.name, () => {
}); });
it('should queue the assets without tags', async () => { it('should queue the assets without tags', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
assetMock.getWithout.mockResolvedValue({ assetMock.getWithout.mockResolvedValue({
items: [assetStub.image], items: [assetStub.image],
hasNextPage: false, hasNextPage: false,
@ -70,6 +79,9 @@ describe(SmartInfoService.name, () => {
}); });
it('should queue all the assets', async () => { it('should queue all the assets', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
assetMock.getAll.mockResolvedValue({ assetMock.getAll.mockResolvedValue({
items: [assetStub.image], items: [assetStub.image],
hasNextPage: false, hasNextPage: false,
@ -103,6 +115,9 @@ describe(SmartInfoService.name, () => {
}); });
it('should save the returned tags', async () => { it('should save the returned tags', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
machineMock.classifyImage.mockResolvedValue(['tag1', 'tag2', 'tag3']); machineMock.classifyImage.mockResolvedValue(['tag1', 'tag2', 'tag3']);
await sut.handleClassifyImage({ id: asset.id }); await sut.handleClassifyImage({ id: asset.id });
@ -121,6 +136,9 @@ describe(SmartInfoService.name, () => {
}); });
it('should always overwrite old tags', async () => { it('should always overwrite old tags', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
machineMock.classifyImage.mockResolvedValue([]); machineMock.classifyImage.mockResolvedValue([]);
await sut.handleClassifyImage({ id: asset.id }); await sut.handleClassifyImage({ id: asset.id });

View File

@ -67,7 +67,7 @@ export const defaults = Object.freeze<SystemConfig>({
enabled: process.env.IMMICH_MACHINE_LEARNING_ENABLED !== 'false', enabled: process.env.IMMICH_MACHINE_LEARNING_ENABLED !== 'false',
url: process.env.IMMICH_MACHINE_LEARNING_URL || 'http://immich-machine-learning:3003', url: process.env.IMMICH_MACHINE_LEARNING_URL || 'http://immich-machine-learning:3003',
classification: { classification: {
enabled: true, enabled: false,
modelName: 'microsoft/resnet-50', modelName: 'microsoft/resnet-50',
minScore: 0.9, minScore: 0.9,
}, },

View File

@ -66,7 +66,7 @@ const updatedConfig = Object.freeze<SystemConfig>({
enabled: true, enabled: true,
url: 'http://immich-machine-learning:3003', url: 'http://immich-machine-learning:3003',
classification: { classification: {
enabled: true, enabled: false,
modelName: 'microsoft/resnet-50', modelName: 'microsoft/resnet-50',
minScore: 0.9, minScore: 0.9,
}, },