Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • v1.0
2 results

face-blurrer

  • Jonathan Windgassen's avatar
    Jonathan Windgassen authored
    ea34e9f0
    History

    Face Blurrer

    This notebook provides a way to use the Faster RCNN Open Images V4 Neural Network, a Neural Network trained on the Open Data Image set to detect various types of objects in given images, to blur and/or identify all kinds of objects in Images and Videos.

    Most of the steps are explained in more detail in the notebook itself, so I will only scratch each topic here.

    Getting started

    As a first step you need to decide whether or not you want to build your own Kernel for the process, as we don't have a native "Machine Learning Kernel" included in our JupyterLab (yet). If you want to use this notebook multiple times I'd encourage you to build the kernel, as it's simpler once you have built it and the alternative is somewhat ugly and bodgy. The bash-script for the kernel can be found in kernel.ipynb

    The face-blurrer expect a certain folder structure where it should look for the Images and Videos and where it should safe them. If you have the Images on a seperate folder, just navigate the script to there. Otherwise create the folderstructure given in the notebook.

    Configuration

    You have a bunch of options when it comes to configure how the scipt is executed. In general I would recommend a testrun with a few images/frames, to make sure that everything is configured correctly.

    General

    • Filter Objects: Here you specify for what object the script shoul look. By default the network will return all found objects, but those will be filtered before the blurring. For most uses Human face or Person is probably the thing you are looking for, but in theory you can pass any object the network can detect. A list to all detectable classes is linked above the cell.
    • Filename after blurring: A string that specifies how each filename will be changed after blurring. With {}_blurred a file like Image1.png would be renamed to Ìmage1_blurred.png
    • Draw boxes: When given True, besides blurring you can also draw a blue box around each object. This might be useful for debugging.
    • Blur onjects: A boolean on whether or not you want to blur the objects. In combination with the option above you can use the notebook to mark all found objects but not do anything else with them.
    • Blur intensity: How intense the blurring of the objects should be. We found 20 to be a good value, but depending on the distance or size of the objects or the reasoning of the blurring you might want to increase or decrease this value.
    • Extend borders: The given rectangles by the network can sometimes be somewhat small and the blur might not cover each part. By adding a fixed amount of pixels to each size, you can remove this possibility, but more of the image will be blurred (If that wasn't obvious)

    Formatting

    • Force Image Size and Force Video Size: By using this option you can automatically convert all Images/Videos to a given size. By leaving any argument at "None" you instruct the scrippt to not change the size. So in theory it's possible to change the ratio (and therefore destort) all images/VIdeos.
    • Crop Video Length: Given a time in seconds, all Videos will be cropped after the given time. Recommended for testing the settings.

    Video Rendering

    • Video Cache Fodler: By default, each frame of a video will be converted to a .png file, all of which will be stored in a tempfile created beforehand and will be deleted afterwards. If you for some reasen want to keep all images, you can specify a folderpath and python will store the images there instead. Be careful however: Python might create Folder there: For each video the created folder is "name-format" and the frames are named consecutively: 1.png, 2.png, 3.png, and so on. OpenCV will override any already existing files with the same name!
    • Force Video Format: By default FFmpeg will use the same format as the input, but you could e.g. force all Video to be ".mp4" or ".mov". Enrer ffmpeg -formats to get all compatible formats.
    • Video Bitrate: The maximum Bitrate for the Videos. If left at "None", FFmpeg will use the default quality setting (-crf 23)
    • Encoder: The encoder ffmped should use. Enter ffmpeg -codecs into a terminal to get all supported Codecs

    File Structure

    All of these Settings lets you customize from where your Images and Videos will be loaded and where they will be stored. You MUST add the "/" behind each path!

    • Image Input Folder: Where to load the Images from.
    • Image Output Folder: Where to store the Images to.
    • Video Input Folder: Where to load the Videos from.
    • Video Output Folder: Where to store the Videos to.

    Known Limitations:

    I am aware of the fact that after compressing the Video to a file the original Audio is lost. I will fix that soon!