wingman-jr-addon / wingman_jr

This is the official repository (https://github.com/wingman-jr-addon/wingman_jr) for the Wingman Jr. Firefox addon, which filters NSFW images in the browser fully client-side: https://addons.mozilla.org/en-US/firefox/addon/wingman-jr-filter/ Optional DNS-blocking using Cloudflare's 1.1.1.1 for families! Also, check out the blog!
https://wingman-jr.blogspot.com/
Other
35 stars 6 forks source link

Video Banner Improvements #159

Closed wingman-jr-addon closed 2 years ago

wingman-jr-addon commented 2 years ago

If you stumble onto something like 4chan, there's a chance you will be met with pornographic video-based banner ads. At the moment, these sometimes slip through despite being quite explicit. There seem to be two reasons why:

  1. The aspect ratio of banner ads is usually long and narrow. This is a known weakness of the prediction model due to these types of images having relatively low representation in the dataset. And on top of that, it's just hard if the banner is say 4x as wide as it is tall. This is similar to the group photos request in #61 (@abdullahezzat1 you may be interested as well here). An approach to solve this would be to allow for predicting based on tiles.
  2. The explicit content starts quite quickly, but not in the first frame scanned. Changing the video scanning logic to go in fast time steps of say 1/4 second for the first 2 seconds or so would probably be a good pragmatic countermeasure.
wingman-jr-addon commented 2 years ago

I think I may take a crack at the prediction tiling here. I have a couple different ideas for approaches.

  1. Roughly, look at the aspect ratio as rounded down integers, then break it up into tiles based on the short side. So, for example, say the image has an aspect ratio of 4.6x1. Then I would say, "that is about 4x1, so I will divide the image up into 4 tiles horizontally". Return the worst score. This has the advantage of being accurate, but the disadvantage of taking more time for multiple scans. This is something I've always been concerned about with this approach.
  2. Do the same tiling breakup as in 1, but instead, then do a best-effort retiling of the parts into an image that is more square. While it may still be hard to preserve the whole image, I suspect this would do significantly better - and it would still only require one scan, which is a big advantage. The downside is that I think the logic may be a bit tricky and it still won't have the full resolution that approach 1 would.

Assuming approach 2 is good enough, it leads to a better user experience, so I'm going to give it a shot and see if I can come up with a suitable algorithm. Watch https://github.com/wingman-jr-addon/wingman_jr/tree/prediction-tiling for any progress.

wingman-jr-addon commented 2 years ago

Ok, I actually like how this turned out so far in #160 - I ended up doing both the tiling and a short video safeguard. Note, the tiling works but sometimes the tiled image still isn't caught just due to the model. Interested parties can uncomment the tiled image output line and run bkSetAllLogging(true) to get a feel for what it's doing. I'm going to let this bake for another day but should be close now.

wingman-jr-addon commented 2 years ago

Looks like it baked fairly well; cleaned up logs and ready to go.