infinitered / nsfwjs

NSFW detection on the client-side via TensorFlow.js
https://nsfwjs.com/
MIT License
7.89k stars 524 forks source link

[Question] Nodejs server side prediction #485

Open chia7 opened 3 years ago

chia7 commented 3 years ago

Hi, is there a way to perform prediction on server side with nodejs, without converting the local image as in the demo code? I would like to directly use fs to read my local file and pass it into the model, is it possible? I supposed that this would largely improve the performance and reduce the running time.

kevinvangelder commented 3 years ago

I think images have to be converted to a tensor before they can be evaluated against the model.

chia7 commented 3 years ago

Got it! Would it be better to use jpeg over png for prediction? Or any other image format you may suggest?

GantMan commented 3 years ago

The fastest way to do this conversion would be to use the TFJS node lib. I haven't updated the demo code bc of time restrictions, but I am releasing a book where I explain how to do this quite clearly:

https://amzn.to/3dR3vpY

Kamel38 commented 3 years ago

I have the same question : I'd like to perform a prediction on serverside with nodejs (firebase cloud functions).

Is there anyway to do that with this package or is it not possible at all ?

GantMan commented 3 years ago

It is completely possible.

I guess I could improve the docs here. But it would be awesome if someone contributed the change.

I explain NodeJS image to tensor directly in my book. But if no one can do it, I can see about setting aside some time at some point.

GantMan commented 3 years ago

@kevinvangelder let me know if this is something you'd like to do. I will, of course, help.

justekoro commented 3 years ago

hi, bumping this :) I recently discovered this module and I'm interested to use it server-side

GantMan commented 3 years ago

Sorry Korobaka, I'll have to find some time and add to the docs. I'll try to find some time this weekend.

justekoro commented 3 years ago

Sorry Korobaka, I'll have to find some time and add to the docs. I'll try to find some time this weekend.

np! take your time :)

dokterbob commented 2 years ago

Hey all, we're working on this!

Our proof of concept: https://github.com/ipfs-search/nsfw-server

Mad props for NSFW.js!

GantMan commented 2 years ago

very cook @dokterbob - I'm planning on adding a voting classifier on top of NSFWJS that will make you able to reallllllly dial in the accuracy vs type 1 and type 2 errors. It should help increase accuracy!

GantMan commented 2 years ago

Also, let me know when you're ready for me to promote NSFW-server on socails!