Skip to content

Commit

Permalink
fix(server): disable classification by default (immich-app#5708)
Browse files Browse the repository at this point in the history
* disable classification by default

* fixed tests
  • Loading branch information
mertalev authored Dec 15, 2023
1 parent 16f3856 commit 4582578
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions server/src/domain/job/job.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ describe(JobService.name, () => {

it('should handle a start object tagging command', async () => {
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 });

Expand Down
2 changes: 1 addition & 1 deletion server/src/domain/server-info/server-info.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe(ServerInfoService.name, () => {
passwordLogin: true,
search: true,
sidecar: true,
tagImage: true,
tagImage: false,
configFile: false,
trash: true,
});
Expand Down
18 changes: 18 additions & 0 deletions server/src/domain/smart-info/smart-info.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ describe(SmartInfoService.name, () => {
});

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 () => {
configMock.load.mockResolvedValue([{ key: SystemConfigKey.MACHINE_LEARNING_ENABLED, value: false }]);

Expand All @@ -58,6 +64,9 @@ describe(SmartInfoService.name, () => {
});

it('should queue the assets without tags', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
assetMock.getWithout.mockResolvedValue({
items: [assetStub.image],
hasNextPage: false,
Expand All @@ -70,6 +79,9 @@ describe(SmartInfoService.name, () => {
});

it('should queue all the assets', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
assetMock.getAll.mockResolvedValue({
items: [assetStub.image],
hasNextPage: false,
Expand Down Expand Up @@ -103,6 +115,9 @@ describe(SmartInfoService.name, () => {
});

it('should save the returned tags', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
machineMock.classifyImage.mockResolvedValue(['tag1', 'tag2', 'tag3']);

await sut.handleClassifyImage({ id: asset.id });
Expand All @@ -121,6 +136,9 @@ describe(SmartInfoService.name, () => {
});

it('should always overwrite old tags', async () => {
configMock.load.mockResolvedValue([
{ key: SystemConfigKey.MACHINE_LEARNING_CLASSIFICATION_ENABLED, value: true },
]);
machineMock.classifyImage.mockResolvedValue([]);

await sut.handleClassifyImage({ id: asset.id });
Expand Down
2 changes: 1 addition & 1 deletion server/src/domain/system-config/system-config.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const defaults = Object.freeze<SystemConfig>({
enabled: process.env.IMMICH_MACHINE_LEARNING_ENABLED !== 'false',
url: process.env.IMMICH_MACHINE_LEARNING_URL || 'http://immich-machine-learning:3003',
classification: {
enabled: true,
enabled: false,
modelName: 'microsoft/resnet-50',
minScore: 0.9,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const updatedConfig = Object.freeze<SystemConfig>({
enabled: true,
url: 'http://immich-machine-learning:3003',
classification: {
enabled: true,
enabled: false,
modelName: 'microsoft/resnet-50',
minScore: 0.9,
},
Expand Down

0 comments on commit 4582578

Please sign in to comment.