Comments (12)
I think it's good, actually. I managed to get it working with this model:
_model = await nsfw.load("https://labs.site.com/nsfwjs/example/nsfw_demo/public/quant_nsfw_mobilenet/")
I also noticed that it's important to download the model using 'git clone'
and not directly from the zip archive. It's strange, I don't understand why.
I confirm it is working now. Here is a summary of the steps to be taken to have the model on our own site/server:
- Download the project directly into a subdomain such as labs.site.com:
git clone https://github.com/infinitered/nsfwjs.git
. Do not download it as a zip file or manually; this is important. - Retrieve the URL (example: https://labs.site.com/nsfwjs/example/nsfw_demo/public/quant_nsfw_mobilenet/) and put it into "
nsfwjs.load('<url>')
" - It should work normally.
from nsfwjs.
same error in my project
0|Cybers Cafe | at Object.fetch (node:internal/deps/undici/undici:11600:11)
0|Cybers Cafe | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
0|Cybers Cafe | cause: Error: getaddrinfo ENOTFOUND d1zv2aa70wpiur.cloudfront.net
0|Cybers Cafe | at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
0|Cybers Cafe | errno: -3007,
0|Cybers Cafe | code: 'ENOTFOUND',
0|Cybers Cafe | syscall: 'getaddrinfo',
0|Cybers Cafe | hostname: 'd1zv2aa70wpiur.cloudfront.net'
0|Cybers Cafe | }
0|Cybers Cafe | }
from nsfwjs.
im using nsfwjs ^2.4.2 in npm
from nsfwjs.
wish i could serve whatever model files are needed from my own server, not have external dependencies. i was unaware of that when i installed it
from nsfwjs.
I specifically ASK you to please download and host the models in the Readme :D
https://github.com/infinitered/nsfwjs?tab=readme-ov-file#host-your-own-model
Please take the models yourself! You can host them wherever or embed them into your page.
from nsfwjs.
Went and paid the bill for our free hosting of the model - it's back
HOWEVER - please host the model yourself 👍
from nsfwjs.
@GantMan I saw this yesterday, I spent 1 hour or 2 hours trying to understand this model thing to download and put it directly in a folder on a site and when I call the url of this model I get this kind of error :
debian@ns:~/node/nsfwjs$ node server.js
...
The kernel 'ZerosLike' for backend 'webgl' is already registered
/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:433
throw new Error(typeof msg === 'string' ? msg : msg());
^Error: Based on the provided shape, [128,5], the tensor should have 640 values but has 632
at assert (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:433:15)
at makeTensor (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:5586:9)
at tensor (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:5654:12)
at Object.decodeWeights (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:5904:29)
at decodeModelAndOptimizerWeights (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:34720:30)
at /home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:34702:26
at step (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:149:27)
at Object.next (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:98:53)
at fulfilled (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:79:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)Node.js v20.5.1
debian@ns:~/node/nsfwjs$
I think there is missing information / a tutorial to be able to install a model directly on our server. I also wasn't aware that I depended on an external model.
I put something like this in my app.js:
const load_model = async () => {
_model = await nsfw.load("https://labs.site.com/nsfwjs/example/nsfw_demo/public/model/")
}
I use @tensorflow/tfjs-node
Could this be a problem with origin cors?
from nsfwjs.
I just downloaded it directly using git clone
to get the model. Here is the new error:
debian@ns:~/node/nsfwjs$ node server.js
...
The kernel 'ZerosLike' for backend 'webgl' is already registered
/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:258
var _this = _super.call(this, message) || this;
^ValueError: Error when checking : expected input_1 to have shape [null,299,299,3] but got array with shape [1,224,224,3].
at new ValueError (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:258:28)
at checkInputData (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:32949:31)
at LayersModel.predict (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:33627:9)
at /home/debian/node/nsfwjs/node_modules/nsfwjs/dist/index.js:132:48
at /home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4562:22
at Engine.scopedRun (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4572:23)
at Engine.tidy (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4561:21)
at Object.tidy (/home/debian/node/nsfwjs/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:8984:19)
at NSFWJS. (/home/debian/node/nsfwjs/node_modules/nsfwjs/dist/index.js:131:37)
at step (/home/debian/node/nsfwjs/node_modules/nsfwjs/dist/index.js:52:23)Node.js v20.5.1
debian@ns:~/node/nsfwjs$
I call the model this way:
_model = await nsfw.load("https://labs.site.com/nsfwjs/example/nsfw_demo/public/model/")
In fact I don't know how to install a model. There is something to put in place that I don't know about.
from nsfwjs.
@GantMan @Madriix Thank you for resolving this so quickly. This is a real enabler for my project. Will try this tomorrow
from nsfwjs.
when i run it from node.js, like this:
const nsfw = require('nsfwjs')
await nsfw.load('file://../nsfwjs/model/');
i get the error:
0|Cybers Cafe | TypeError: fetch failed
0|Cybers Cafe | at Object.fetch (node:internal/deps/undici/undici:11600:11)
0|Cybers Cafe | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
0|Cybers Cafe | cause: Error: not implemented... yet...
0|Cybers Cafe | at makeNetworkError (node:internal/deps/undici/undici:6911:35)
0|Cybers Cafe | at schemeFetch (node:internal/deps/undici/undici:11050:18)
0|Cybers Cafe | at node:internal/deps/undici/undici:10930:26
0|Cybers Cafe | at mainFetch (node:internal/deps/undici/undici:10947:11)
0|Cybers Cafe | at fetching (node:internal/deps/undici/undici:10904:7)
0|Cybers Cafe | at fetch2 (node:internal/deps/undici/undici:10782:20)
0|Cybers Cafe | at Object.fetch (node:internal/deps/undici/undici:11598:18)
0|Cybers Cafe | at fetch (node:internal/process/pre_execution:274:25)
0|Cybers Cafe | at PlatformNode.fetch (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:7425:33)
0|Cybers Cafe | at HTTPRequest.<anonymous> (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:8289:55)
0|Cybers Cafe | }
from nsfwjs.
It's fetch...
https://stackoverflow.com/questions/74769009/fetch-local-files-with-node-js
guess i'll just host the files for the host itself to use...
in the future maybe use fs module
from nsfwjs.
@GantMan
i got it working reading locally. heres the code (node.js):
const tf = require('@tensorflow/tfjs-node');
const nsfw = require('nsfwjs')
let nsfwModel = null;
async function getNsfwModel () {
if (nsfwModel == null) {
const ioHandlerFs = tf.io.fileSystem("./nsfwjs/model/model.json");
nsfwModel = await nsfw.load(ioHandlerFs, {size: 299, type: "layers"});
}
return nsfwModel;
}
without size parameter i get an error, even though i see that the defalut is not 299:
const IMAGE_SIZE = 224; // default to Mobilenet v2
heres the error:
0|Cybers Cafe | ValueError: Error when checking : expected input_1 to have shape [null,299,299,3] but got array with shape [1,224,224,3].
0|Cybers Cafe | at new ValueError (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:258:28)
0|Cybers Cafe | at checkInputData (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:32949:31)
0|Cybers Cafe | at LayersModel.predict (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-layers/dist/tf-layers.node.js:33627:9)
0|Cybers Cafe | at /home/jordan/neo/cybers-cafe/node_modules/nsfwjs/dist/index.js:132:48
0|Cybers Cafe | at /home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4562:22
0|Cybers Cafe | at Engine.scopedRun (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4572:23)
0|Cybers Cafe | at Engine.tidy (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:4561:21)
0|Cybers Cafe | at Object.tidy (/home/jordan/neo/cybers-cafe/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:8984:19)
0|Cybers Cafe | at NSFWJS.<anonymous> (/home/jordan/neo/cybers-cafe/node_modules/nsfwjs/dist/index.js:131:37)
0|Cybers Cafe | at step (/home/jordan/neo/cybers-cafe/node_modules/nsfwjs/dist/index.js:52:23)
from nsfwjs.
Related Issues (20)
- [False Positive]: a little bit funny HOT 2
- Which model is the best atm? Resources hardware is not a problem. inception_v4?
- I really need to run this locally for batch processing local images any guides tutorials? HOT 2
- How to use the Inception V3 model in the npm package?
- when adding a frame to an nsfw picture...
- Problem detecting adult content from camera images
- Cant import nsfw in react Project HOT 2
- Logs spammed by tfjs-node launched twice
- Not work local model load HOT 3
- The accuracy is much less than the site HOT 1
- Broken with the recent file on next.js HOT 4
- Publish to npm out of sync HOT 3
- `console.warn` when `BASE_PATH` is used on load
- Remove GIF Support HOT 1
- False Positive HOT 1
- type: "graph" vs size: 299 HOT 1
- Mismatch in the published package content. HOT 1
- MobileNetV2Mid doesn't load HOT 3
- NSFW through Docker reports an error - maybe provide Docker support? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsfwjs.