Skip to content

Cannot load latest (v1.1) nsfw_model from local file #512

@jonbarrow

Description

@jonbarrow

I currently have the latest nsfw_model found at https://github.com/GantMan/nsfw_model/releases/tag/1.1.0 and am trying to load it as a local file like so:

const model = await nsfw.load('file://' + __dirname + '/mobilenet_v2_140_224/web_model_quantized/');

However this results in the following error:

(node:28129) UnhandledPromiseRejectionWarning: Error: layer: Improper config format: (LARGE JSON OBJECT HERE).
'className' and 'config' must set.

I tried the solution found in #397, specifically this comment, however when running npm install @tensorflow/tfjs@^1.7.4 I get:

npm ERR! 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: @tensorflow/tfjs@1.7.4
npm ERR! node_modules/@tensorflow/tfjs
npm ERR!   @tensorflow/tfjs@"^1.7.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @tensorflow/tfjs@"^3.1.0" from nsfwjs@2.4.0
npm ERR! node_modules/nsfwjs
npm ERR!   nsfwjs@"^2.4.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/jon/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jon/.npm/_logs/2021-05-07T15_30_17_117Z-debug.logcode ERESOLVE

Running npm install @tensorflow/tfjs@^1.7.4 --force works to install that version but then the load function fails to load a local file, saying only absolute URLs are supported

@tensorflow/tfjs-node: ^3.6.1
nsfwjs: ^2.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions