summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/AiService.ts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2025-09-06 17:48:53 +0900
committerGitHub <noreply@github.com>2025-09-06 17:48:53 +0900
commit369f0ec88ac2ac578cff51d7abc6b575de26ceb2 (patch)
treec488e486332b370ca6e1a198f87f59c61cb394e9 /packages/backend/src/core/AiService.ts
parentenhance(frontend): フロントエンドのキャッシュクリア操作で... (diff)
downloadmisskey-369f0ec88ac2ac578cff51d7abc6b575de26ceb2.tar.gz
misskey-369f0ec88ac2ac578cff51d7abc6b575de26ceb2.tar.bz2
misskey-369f0ec88ac2ac578cff51d7abc6b575de26ceb2.zip
fix(backend): webpなどの画像に対してセンシティブなメディアの検出が適用されていなかった問題を修正 (#16523)
画像をnsfwjsにかける前にsharpで均一にするようにした
Diffstat (limited to 'packages/backend/src/core/AiService.ts')
-rw-r--r--packages/backend/src/core/AiService.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/packages/backend/src/core/AiService.ts b/packages/backend/src/core/AiService.ts
index 248a9b8979..23ab8082ed 100644
--- a/packages/backend/src/core/AiService.ts
+++ b/packages/backend/src/core/AiService.ts
@@ -29,7 +29,7 @@ export class AiService {
}
@bindThis
- public async detectSensitive(path: string): Promise<nsfw.PredictionType[] | null> {
+ public async detectSensitive(source: string | Buffer): Promise<nsfw.PredictionType[] | null> {
try {
if (isSupportedCpu === undefined) {
isSupportedCpu = await this.computeIsSupportedCpu();
@@ -51,7 +51,7 @@ export class AiService {
});
}
- const buffer = await fs.promises.readFile(path);
+ const buffer = source instanceof Buffer ? source : await fs.promises.readFile(source);
const image = await tf.node.decodeImage(buffer, 3) as any;
try {
const predictions = await this.model.classify(image);