1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 22:45:40 +02:00

fix(backend): webpなどの画像に対してセンシティブなメディアの検出が適用されていなかった問題を修正 (#16523)

画像をnsfwjsにかける前にsharpで均一にするようにした
This commit is contained in:
tamaina
2025-09-06 17:48:53 +09:00
committed by GitHub
parent 788c5660ba
commit 369f0ec88a
2 changed files with 21 additions and 12 deletions

View File

@@ -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);