From c6b37bc5e3a24e21a34a9fb6963988522e04c9c1 Mon Sep 17 00:00:00 2001 From: HotoRas Date: Wed, 9 Oct 2024 14:24:54 +0900 Subject: [PATCH] Fix (backend): nsfwjs import/export issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit import문에 require를 겹치는 게 됐었구나 (eslint에 금지된 거긴 한데 cjs로 임포트해야 돼서 얘 말고 답이 없음) --- packages/backend/src/core/AiService.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/AiService.ts b/packages/backend/src/core/AiService.ts index ad852fdd6e6e..7ec6098a452f 100644 --- a/packages/backend/src/core/AiService.ts +++ b/packages/backend/src/core/AiService.ts @@ -7,7 +7,9 @@ import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname } from 'node:path'; import { Injectable } from '@nestjs/common'; -import * as nsfw from 'nsfwjs'; +// eslint-disable-next-line @typescript-eslint/no-require-imports +import nsfw = require('nsfwjs'); +import { Tensor3D } from '@tensorflow/tfjs-core'; import si from 'systeminformation'; import { Mutex } from 'async-mutex'; import { bindThis } from '@/decorators.js'; @@ -51,7 +53,7 @@ export class AiService { } const buffer = await fs.promises.readFile(path); - const image = await tf.node.decodeImage(buffer, 3) as any; + const image = await tf.node.decodeImage(buffer as any, 3) as Tensor3D; try { const predictions = await this.model.classify(image); return predictions;