Can I save the model to a browser locally and run it?
Hi,
I am trying to use nsfwjs with TensorFlow JS to build an app. I am pretty new to this so I was wondering how I can use the model locally. i.e I need to be able to download the model files to my project folder and use it by importing it into a JS file. I see that I can use the model that you have hosted in S3. How can I go about without such hosting?
I want to prevent loading the model every time the user uses my app. Instead I plan to store the model on his device locally. That way, it needs to load the model only the first time it is used. Please help!
Thanks!
Yup! You can save it locally, I actually prefer that. ALSO the browser will cache it!
See this section on how to tell the library where the model is located: https://github.com/infinitered/nsfwjs#load-the-model
So like, I can just download the file there and add it to my project folder and just provide the url to the model?
I have just installed tfjs and nsfwjs using npm. So I should just import the files and it would work fine?
Sorry, I am a noob at this, I could not find any solution anywhere else
No problem! It can be confusing :)
When you say "locally" do you mean you're copying the files to your server, or do you mean you're making a web page on your desktop?
You can just put these files in a folder, and point it there: https://github.com/infinitered/nsfwjs/tree/master/example/nsfw_demo/public/quant_mid
I am using it to build a chrome extension. So it would be in my desktop and not on any server. I will try this out and check if it is working!
Thank you so much!
No problem! Put the files in a models folder and don't forget to set
"web_accessible_resources": ["images/*", "models/*"],
in your manifest.json so the script can access them.
I will try that!
Yes! It seems to work! Thanks!
Would it be okay if I mention you guys in a LinkedIn post. I would like to share my project and I would like tag you guys. Could I do it?
yup!!!
https://www.linkedin.com/posts/navendup_navendu-pottekkatnsfw-filter-activity-6689531508220411905-lUw2