Skip to content

Commit

Permalink
Fix (backend): nsfwjs import/export issue
Browse files Browse the repository at this point in the history
import문에 require를 겹치는 게 됐었구나
(eslint에 금지된 거긴 한데 cjs로 임포트해야 돼서 얘 말고 답이 없음)
  • Loading branch information
HotoRas committed Oct 9, 2024
1 parent 4d704e3 commit c6b37bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/backend/src/core/AiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c6b37bc

Please sign in to comment.