wingman-jr-addon / model

The model for filtering NSFW images backing the Wingman Jr. plugin: https://github.com/wingman-jr-addon/wingman_jr
Creative Commons Zero v1.0 Universal
5 stars 0 forks source link

How to test with another pre-trained model #1

Closed kiran-collab closed 3 years ago

kiran-collab commented 3 years ago

Hello! I am working on the project that blocks the obscense images from browser using an addon. If i want to put another pre trained model and use the addon, what changes should I do? I would be grateful if someone can address the query as soon as possible! Thankyou!

wingman-jr-addon commented 3 years ago

@kiran-collab I think your question is a little like saying "I have a car with one engine, how can I drop in your engine?" Each car and engine tends to be a bit different, so if you walked in and asked a mechanic that you're not likely to get the answer you're looking for exactly. If you were to ask it more specifically you might get a long and complex answer; but a generic question like this is not terribly helpful - you actually have to roll up your sleeves and get to work looking at how other concrete examples work and then come back with specific questions. I'll see if I can provide some general help below, but I plan to close this issue out. Give your experiment a try and come back if something about this model specifically is not working out!

You can take a look at how this model is used in the browser plugin I make called Wingman Jr. Fortunately, unlike a car engine, the integration into your own plugin could be much easier. The input to the model (at least for sqrxr_62) is simply a 224x224 MobileNetV2 image. The output should use the ROC provided.

Relevant code bits: Model startup section Prediction code Test against the ROC score

kiran-collab commented 3 years ago

@wingman-jr-addon, thankyou! Actually I need to submit the project soon. Hence I request you if there is a faster way that you can suggest, like editing a certain code snippet or just adding the model. If possible, kindly give some steps that I can follow. I request you this as you are more aware about the code. I have to go through the whole code, which would take time!

wingman-jr-addon commented 3 years ago

@kiran-collab Well I pointed at specific code bits that do the main work. The general steps for using this (or most Tensorflow.js models):

  1. Load the model. See the "Model startup section" from above.
  2. Optionally, send an empty image through the model to "warm it up". The first prediction is quite slow and later ones are faster. That same code section does that.
  3. Get your image somehow. In this case, probably best to have it in an <img> element or an Image.
  4. Prepare the image to be in the right format for the model. This is is in the "Prediction code" section above.
  5. Get the model prediction.
  6. Compare against the ROC curve threshold cutoff to find the true positive vs. false positive rate at that threshold; you could compare for score[0] < 0.9903306 as a starting point.

What specific task are you trying to figure out how to do? Also please note that I do include the .h5 files as well if you are using Python.

wingman-jr-addon commented 3 years ago

@kiran-collab Any luck so far?

kiran-collab commented 3 years ago

@wingman-jr-addon heyy, sorry for the late reply. I have understood the concept! I am modifying it. I am extremely thankful! I would ping you incase any issue. Btw, I wish to ask if there is any add on that works the same way for videos?

wingman-jr-addon commented 3 years ago

I do not currently know of any; I am working on video support currently. Let me know if you do find one. If you are curious, I am also blogging about the video implementation here: https://wingman-jr.blogspot.com/2021/01/video-new-challenge.html