Before you read: (It's probably more of a package issue, but I need it to work with Nuxt and Vite) I need it done asap and can offer a small tip
Has anyone used the nsfwjs https://www.npmjs.com/package/nsfwjs package with nuxt? I am having issue in my Nuxt 3 (with spa mode) project. I believe the problem is related to Vite because the package works correctly in a barebone React project as per the documentation.
In particular: with the following imports as per docs
import * as tf from "@tensorflow/tfjs";import * as nsfwjs from "nsfwjs";
import * as tf from "@tensorflow/tfjs";import * as nsfwjs from "nsfwjs";
It throws an error right after this line:
const model = await nsfwjs.load("MobileNetV2Mid");
const model = await nsfwjs.load("MobileNetV2Mid");
nsfwjs.js?v=0f6cacb3:217 Uncaught (in promise) Error: Could not load the model. Make sure you are importing the model.min.js bundle. at nsfwjs.js?v=0f6cacb3:217:17 at step (nsfwjs.js?v=0f6cacb3:110:17) at Object.next (nsfwjs.js?v=0f6cacb3:62:14) at nsfwjs.js?v=0f6cacb3:49:67 at new Promise (<anonymous>) at __awaiter (nsfwjs.js?v=0f6cacb3:31:10) at loadModel (nsfwjs.js?v=0f6cacb3:195:10) at Module.<anonymous> (nsfwjs.js?v=0f6cacb3:249:22) at step (nsfwjs.js?v=0f6cacb3:110:17) at Object.next (nsfwjs.js?v=0f6cacb3:62:14)
nsfwjs.js?v=0f6cacb3:217 Uncaught (in promise) Error: Could not load the model. Make sure you are importing the model.min.js bundle. at nsfwjs.js?v=0f6cacb3:217:17 at step (nsfwjs.js?v=0f6cacb3:110:17) at Object.next (nsfwjs.js?v=0f6cacb3:62:14) at nsfwjs.js?v=0f6cacb3:49:67 at new Promise (<anonymous>) at __awaiter (nsfwjs.js?v=0f6cacb3:31:10) at loadModel (nsfwjs.js?v=0f6cacb3:195:10) at Module.<anonymous> (nsfwjs.js?v=0f6cacb3:249:22) at step (nsfwjs.js?v=0f6cacb3:110:17) at Object.next (nsfwjs.js?v=0f6cacb3:62:14)
Does anyone have any idea how to fix that package or make vite import .js files correctly?