Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
merge: remove tensorflow, AiService (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marie authored Nov 5, 2023
2 parents e50ac8c + c1f9670 commit ecf63c4
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 944 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,5 @@
"cypress": "13.4.0",
"eslint": "8.52.0",
"start-server-and-test": "2.0.1"
},
"optionalDependencies": {
"@tensorflow/tfjs-core": "4.4.0"
}
}
Binary file removed packages/backend/nsfw-model/group1-shard1of6
Binary file not shown.
2 changes: 0 additions & 2 deletions packages/backend/nsfw-model/group1-shard2of6

This file was deleted.

3 changes: 0 additions & 3 deletions packages/backend/nsfw-model/group1-shard3of6

This file was deleted.

3 changes: 0 additions & 3 deletions packages/backend/nsfw-model/group1-shard4of6

This file was deleted.

18 changes: 0 additions & 18 deletions packages/backend/nsfw-model/group1-shard5of6

This file was deleted.

3 changes: 0 additions & 3 deletions packages/backend/nsfw-model/group1-shard6of6

This file was deleted.

1 change: 0 additions & 1 deletion packages/backend/nsfw-model/model.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
"@swc/core-win32-arm64-msvc": "1.3.56",
"@swc/core-win32-ia32-msvc": "1.3.56",
"@swc/core-win32-x64-msvc": "1.3.56",
"@tensorflow/tfjs": "4.4.0",
"@tensorflow/tfjs-node": "4.4.0",
"bufferutil": "4.0.7",
"slacc-android-arm-eabi": "0.0.10",
"slacc-android-arm64": "0.0.10",
Expand Down Expand Up @@ -129,7 +127,6 @@
"nested-property": "4.0.0",
"node-fetch": "3.3.2",
"nodemailer": "6.9.7",
"nsfwjs": "2.4.2",
"oauth": "0.10.0",
"oauth2orize": "1.12.0",
"oauth2orize-pkce": "0.1.2",
Expand Down
72 changes: 0 additions & 72 deletions packages/backend/src/core/AiService.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/backend/src/core/CoreModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { Module } from '@nestjs/common';
import { AccountMoveService } from './AccountMoveService.js';
import { AccountUpdateService } from './AccountUpdateService.js';
import { AiService } from './AiService.js';
import { AnnouncementService } from './AnnouncementService.js';
import { AntennaService } from './AntennaService.js';
import { AppLockService } from './AppLockService.js';
Expand Down Expand Up @@ -139,7 +138,6 @@ import type { Provider } from '@nestjs/common';
const $LoggerService: Provider = { provide: 'LoggerService', useExisting: LoggerService };
const $AccountMoveService: Provider = { provide: 'AccountMoveService', useExisting: AccountMoveService };
const $AccountUpdateService: Provider = { provide: 'AccountUpdateService', useExisting: AccountUpdateService };
const $AiService: Provider = { provide: 'AiService', useExisting: AiService };
const $AnnouncementService: Provider = { provide: 'AnnouncementService', useExisting: AnnouncementService };
const $AntennaService: Provider = { provide: 'AntennaService', useExisting: AntennaService };
const $AppLockService: Provider = { provide: 'AppLockService', useExisting: AppLockService };
Expand Down Expand Up @@ -276,7 +274,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
LoggerService,
AccountMoveService,
AccountUpdateService,
AiService,
AnnouncementService,
AntennaService,
AppLockService,
Expand Down Expand Up @@ -406,7 +403,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$LoggerService,
$AccountMoveService,
$AccountUpdateService,
$AiService,
$AnnouncementService,
$AntennaService,
$AppLockService,
Expand Down Expand Up @@ -537,7 +533,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
LoggerService,
AccountMoveService,
AccountUpdateService,
AiService,
AnnouncementService,
AntennaService,
AppLockService,
Expand Down Expand Up @@ -666,7 +661,6 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$LoggerService,
$AccountMoveService,
$AccountUpdateService,
$AiService,
$AnnouncementService,
$AntennaService,
$AppLockService,
Expand Down
29 changes: 2 additions & 27 deletions packages/backend/src/core/DriveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,35 +461,11 @@ export class DriveService {
requestHeaders = null,
ext = null,
}: AddFileArgs): Promise<MiDriveFile> {
let skipNsfwCheck = false;
const instance = await this.metaService.fetch();
const userRoleNSFW = user && (await this.roleService.getUserPolicies(user.id)).alwaysMarkNsfw;
if (user == null) {
skipNsfwCheck = true;
} else if (userRoleNSFW) {
skipNsfwCheck = true;
}
if (instance.sensitiveMediaDetection === 'none') skipNsfwCheck = true;
if (user && instance.sensitiveMediaDetection === 'local' && this.userEntityService.isRemoteUser(user)) skipNsfwCheck = true;
if (user && instance.sensitiveMediaDetection === 'remote' && this.userEntityService.isLocalUser(user)) skipNsfwCheck = true;

const info = await this.fileInfoService.getFileInfo(path, {
skipSensitiveDetection: skipNsfwCheck,
sensitiveThreshold: // 感度が高いほどしきい値は低くすることになる
instance.sensitiveMediaDetectionSensitivity === 'veryHigh' ? 0.1 :
instance.sensitiveMediaDetectionSensitivity === 'high' ? 0.3 :
instance.sensitiveMediaDetectionSensitivity === 'low' ? 0.7 :
instance.sensitiveMediaDetectionSensitivity === 'veryLow' ? 0.9 :
0.5,
sensitiveThresholdForPorn: 0.75,
enableSensitiveMediaDetectionForVideos: instance.enableSensitiveMediaDetectionForVideos,
});
this.registerLogger.info(`${JSON.stringify(info)}`);

// 現状 false positive が多すぎて実用に耐えない
//if (info.porn && instance.disallowUploadWhenPredictedAsPorn) {
// throw new IdentifiableError('282f77bf-5816-4f72-9264-aa14d8261a21', 'Detected as porn.');
//}
const info = await this.fileInfoService.getFileInfo(path);
this.registerLogger.info(`${JSON.stringify(info)}`);

// detect name
const detectedName = correctFilename(
Expand Down Expand Up @@ -586,7 +562,6 @@ export class DriveService {
: false;

if (info.sensitive && profile!.autoSensitive) file.isSensitive = true;
if (info.sensitive && instance.setSensitiveFlagAutomatically) file.isSensitive = true;
if (userRoleNSFW) file.isSensitive = true;

if (url !== null) {
Expand Down
Loading

0 comments on commit ecf63c4

Please sign in to comment.