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

type: "graph" vs size: 299 #831

Open
ghnp5 opened this issue Mar 5, 2024 · 2 comments
Open

type: "graph" vs size: 299 #831

ghnp5 opened this issue Mar 5, 2024 · 2 comments

Comments

@ghnp5
Copy link

ghnp5 commented Mar 5, 2024

Hello

If I'm using this model - https://github.com/infinitered/nsfwjs/tree/master/models/inception_v3

Is it incorrect that I'm loading it this way?

nsfw.load('file://./model/', { size: 299 });


I'm asking because I noticed this in the README:

Model InceptionV3 - [Graph](https://github.com/infinitered/nsfwjs/tree/master/models/mobilenet_v2_mid)

const model = nsfwjs.load("/path/to/different/model/", { type: "graph" });

But because the link is incorrect, I'm not sure which is which.

The correct link for InceptionV2 is here:

Model MobileNetV2Mid - [299x299](https://github.com/infinitered/nsfwjs/tree/master/models/inception_v3)

const model = nsfwjs.load("/path/to/different/model/", { size: 299 });

Thank you!

@ghnp5
Copy link
Author

ghnp5 commented Mar 6, 2024

After updating, I'm also trying to load by just calling:

const nsfw = require('nsfwjs');
(...)
_model_layer = await nsfw.load('InceptionV3');

But I'm getting:

nsfwjs | /dock/node_modules/nsfwjs/dist/cjs/index.js:158
nsfwjs | throw new Error("Could not load the model. Make sure you are importing the model.min.js bundle.");
nsfwjs | ^
nsfwjs |
nsfwjs | Error: Could not load the model. Make sure you are importing the model.min.js bundle.
nsfwjs | at /dock/node_modules/nsfwjs/dist/cjs/index.js:158:27
nsfwjs | at step (/dock/node_modules/nsfwjs/dist/cjs/index.js:56:23)
nsfwjs | at Object.throw (/dock/node_modules/nsfwjs/dist/cjs/index.js:37:53)
nsfwjs | at rejected (/dock/node_modules/nsfwjs/dist/cjs/index.js:29:65)
nsfwjs | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
nsfwjs |
nsfwjs | Node.js v21.6.2

If I try using what's in the README, using "graph":

_model_layer = await nsfw.load('file://./model/', { type: "graph" });

I get:

nsfwjs | /dock/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:32096
nsfwjs | this.version = "".concat(graph.versions.producer, ".").concat(graph.versions.minConsumer);
nsfwjs | ^
nsfwjs |
nsfwjs | TypeError: Cannot read properties of undefined (reading 'producer')
nsfwjs | at GraphModel.loadWithWeightMap (/dock/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:32096:49)
nsfwjs | at GraphModel.loadSync (/dock/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:32063:21)
nsfwjs | at /dock/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:32048:34

So, the only thing that works for me is if I use what I had originally:

_model_layer = await nsfw.load('file://./model/', { size: 299 });

I believe the README is still incorrect, even after the last update you made earlier after my comments in the PR.

Thanks.

@AlexUrrutia
Copy link

@ghnp5 same here ...

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

No branches or pull requests

2 participants