Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to cloudfront.net since this morning #808

Open
Madriix opened this issue Dec 22, 2023 · 12 comments
Open

Error connecting to cloudfront.net since this morning #808

Madriix opened this issue Dec 22, 2023 · 12 comments
Labels
question Further information is requested

Comments

@Madriix
Copy link
Contributor

Madriix commented Dec 22, 2023

The server refuses to start with "node app.js" since this morning, it indicates that this url is not found:

"https://d1zv2aa70wpiur.cloudfront.net/tfjs_quant_nsfw_mobilenet/";

node:internal/deps/undici/undici:11576
    Error.captureStackTrace(err, this);
          ^

TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11576:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: Error: getaddrinfo ENOTFOUND d1zv2aa70wpiur.cloudfront.net
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
    errno: -3007,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd1zv2aa70wpiur.cloudfront.net'
  }
}

Will it work again or should I install a model at home? How to have the same model?

@nonki72
Copy link

nonki72 commented Dec 22, 2023

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          | }

@nonki72
Copy link

nonki72 commented Dec 22, 2023

im using nsfwjs ^2.4.2 in npm

@nonki72
Copy link

nonki72 commented Dec 22, 2023

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

@GantMan
Copy link
Member

GantMan commented Dec 22, 2023

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.

@GantMan GantMan added the question Further information is requested label Dec 22, 2023
@GantMan
Copy link
Member

GantMan commented Dec 22, 2023

Went and paid the bill for our free hosting of the model - it's back

HOWEVER - please host the model yourself 👍

@Madriix
Copy link
Contributor Author

Madriix commented Dec 23, 2023

@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?

@Madriix
Copy link
Contributor Author

Madriix commented Dec 23, 2023

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.

@Madriix
Copy link
Contributor Author

Madriix commented Dec 23, 2023

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:

  1. 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.
  2. Retrieve the URL (example: https://labs.site.com/nsfwjs/example/nsfw_demo/public/quant_nsfw_mobilenet/) and put it into "nsfwjs.load('<url>')"
  3. It should work normally.

@nonki72
Copy link

nonki72 commented Dec 23, 2023

@GantMan @Madriix Thank you for resolving this so quickly. This is a real enabler for my project. Will try this tomorrow

@nonki72
Copy link

nonki72 commented Dec 23, 2023

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          | }

@nonki72
Copy link

nonki72 commented Dec 27, 2023

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

@nonki72
Copy link

nonki72 commented Dec 27, 2023

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants