infinitered/nsfwjs

NSWF.js on React Native

FranciscoOssian opened this issue · 2 comments

I was creating a teste app with Tensorflow and nsfw model available at infinitered repo infinitered/nsfwjs-mobile
Works, but without nsfw.js module, and the predictions were wrong, I don't know the best place to throw these two questions.

1 - What would be the best decision making to use in react native?

2 - The model in infinitered/nsfwjs-mobile its just a demo? but why would that model be giving wrong predictions? (I was having predictions that every time an image was classified as "safe"). Right now I discovered this module GantMan/nsfw_model , is it something more official and reliable?

The NSFW.js module loads a lot of node.js and html references, none of which will be used in react native.
In order for me to be able to use the template they made available in /nsfwjs-mobile, I had to pull out of the original package just a few functions to get the ratings. I don't know if the error is in the model or in something wrong that I did when extracting. Follow issue # 24 in the mobile repository, NSFWJS-not-working-in-react-native

It's been a while since I've see TFJS on React Native, so I'll see what I can do to help.

1 - I haven't put TFJS on RN in a bit. But here's what I would do if I needed to ship NSFWJS blind. I'd see about converting the model to a TFLite model. TFLite is meant for on-device inference at extreme speeds. It takes little power and is generally great if all you want to do is "USE" a model. Once converted, you could search for any ReactNative TFLite library to consume the resulting model and call it from JavaScript. YES... this might mean you need to understand a little more, but I'm optimizing for effect and success.

2 - I don't understand the phrase "why would it be giving dotted forecasts for just one prediction". The most reliable and official models reside here: https://github.com/infinitered/nsfwjs/tree/master/example/nsfw_demo/public
They are in the folders model, quant_mid, and quant_nsfw_mobilenet. I know the naming of these 3 folders and their location is terrible. That's something we should fix. All 3 are in TFJS form and would need to be converted.

Here's the top result from StackOverflow on how to convert the models: https://stackoverflow.com/questions/62544836/how-to-convert-from-tensorflow-js-json-model-into-tensorflow-savedmodel-or

I feel like the code from 3 years ago is pretty non-functional these days. It would take some effort, but a NSFWJS React Native demo could be created and updated. Please share what you find.

cc: @kevinvangelder and maybe @cdanwards

2 - I don't understand the phrase "why would it be giving dotted forecasts for just one prediction". The most reliable and official models reside here: https://github.com/infinitered/nsfwjs/tree/master/example/nsfw_demo/public They are in the folders model, quant_mid, and quant_nsfw_mobilenet. I know the naming of these 3 folders and their location is terrible. That's something we should fix. All 3 are in TFJS form and would need to be converted.

Here's the top result from StackOverflow on how to convert the models: https://stackoverflow.com/questions/62544836/how-to-convert-from-tensorflow-js-json-model-into-tensorflow-savedmodel-or

I feel like the code from 3 years ago is pretty non-functional these days. It would take some effort, but a NSFWJS React Native demo could be created and updated. Please share what you find.
cc: @kevinvangelder and maybe @cdanwards

The repo exemplate of nsfw.js in react native has a model left there, I understood that its was the ideal. Thanks for the answer I'll research more about .tflite and this official model.
I used a bit of a translator, sorry. I was talking about the react-native repo, model was returning strange predictions. In the issue that I pointed out I sent an example.