I was trying to load the face-api.js models in an Nextjs app but keep getting the error
Unhandled Runtime Error Error: Failed to parse URL from /model/ssd_mobilenetv1_model-weights_manifest.json
This is weird cause it happends on Nextjs only while i dont have any problems on a normal nodejs app.
code:
import * as faceapi from 'face-api.js';
import fs from 'fs';
export async function loadingModels() {
const exists = fs.existsSync('public/model/tiny_face_detector_model-weights_manifest.json');
console.log(exists)
await faceapi.nets.ssdMobilenetv1.load('/model')
}
I thought that its because i placed my models in the wrong place but i checked and it is there. It just wont load :((
--
In .env file, add below line.
Updated:
Try to import the file .
Reference https://stackoverflow.com/questions/76145893/how-do-i-pull-my-data-from-my-json-file-in-the-public-folder-in-nextjs-13-3