Whiteboard Inpainting Python* Demo¶
This demo focuses on a whiteboard text overlapped by a person. The demo shows how to use the OpenVINO™ toolkit to detect and hide a person on a video so that all text on a whiteboard is visible.
How It Works¶
The demo expects one of the following models in the Intermediate Representation (IR) format:
Instance segmentation model
Semantic segmentation model
As an input, the demo application takes:
Path to a video file
Index of a web camera
By default, Open Model Zoo demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the demo application or reconvert your model using the Model Optimizer tool with the
--reverse_input_channels argument specified. For more information about the argument, refer to When to Reverse Input Channels section of Converting a Model Using General Conversion Parameters.
Preparing to Run¶
For demo input image or video files, refer to the section Media Files Available for Demos in the Open Model Zoo Demos Overview. The list of models supported by the demo is in
<omz_dir>/demos/whiteboard_inpainting_demo/python/models.lst file. This file can be used as a parameter for Model Downloader and Converter to download and, if necessary, convert models to OpenVINO Inference Engine format (*.xml + *.bin).
An example of using the Model Downloader:
python3 <omz_dir>/tools/downloader/downloader.py --list models.lst
An example of using the Model Converter:
python3 <omz_dir>/tools/downloader/converter.py --list models.lst
To install required dependencies, open a terminal and run the following:
pip3 install -r requirements.txt
Run the application with the
-h option to see the following usage message:
usage: whiteboard_inpainting_demo.py [-h] -i INPUT [--loop] [-o OUTPUT] [-limit OUTPUT_LIMIT] -m_i M_INSTANCE_SEGMENTATION -m_s M_SEMANTIC_SEGMENTATION [-t THRESHOLD] [--no_show] [-d DEVICE] [-l CPU_EXTENSION] [-u UTILIZATION_MONITORS] Whiteboard inpainting demo optional arguments: -h, --help Show this help message and exit. -i INPUT, --input INPUT Required. Path to a video file or a device node of a webcam. --loop Optional. Enable reading the input in a loop. -o OUTPUT, --output OUTPUT Optional. Name of the output file(s) to save. -limit OUTPUT_LIMIT, --output_limit OUTPUT_LIMIT Optional. Number of frames to store in output. If 0 is set, all frames are stored. -m_i M_INSTANCE_SEGMENTATION, --m_instance_segmentation M_INSTANCE_SEGMENTATION Required. Path to the instance segmentation model. -m_s M_SEMANTIC_SEGMENTATION, --m_semantic_segmentation M_SEMANTIC_SEGMENTATION Required. Path to the semantic segmentation model. -t THRESHOLD, --threshold THRESHOLD Optional. Threshold for person instance segmentation model. --no_show Optional. Don't show output. -d DEVICE, --device DEVICE Optional. Specify a target device to infer on. CPU, GPU, HDDL or MYRIAD is acceptable. The demo will look for a suitable plugin for the device specified. -l CPU_EXTENSION, --cpu_extension CPU_EXTENSION MKLDNN (CPU)-targeted custom layers. Absolute path to a shared library with the kernels impl. -u UTILIZATION_MONITORS, --utilization_monitors UTILIZATION_MONITORS Optional. List of monitors to show initially.
Example of a command:
python3 whiteboard_inpainting_demo.py \ -i <path_to_video>/video.avi \ -m_i <path_to_model>/instance-segmentation-security-0228.xml
You can save processed results to a Motion JPEG AVI file or separate JPEG or PNG files using the
To save processed results in an AVI file, specify the name of the output file with
aviextension, for example:
To save processed results as images, specify the template name of the output image file with
pngextension, for example:
-o output_%03d.jpg. The actual file names are constructed from the template at runtime by replacing regular expression
%03dwith the frame number, resulting in the following:
output_001.jpg, and so on. To avoid disk space overrun in case of continuous input stream, like camera, you can limit the amount of data stored in the output file(s) with the
limitoption. The default value is 1000. To change it, you can apply the
-limit Noption, where
Nis the number of frames to store.
> NOTE : Windows* systems may not have the Motion JPEG codec installed by default. If this is the case, you can download OpenCV FFMPEG back end using the PowerShell script provided with the OpenVINO install package and located at
<INSTALL_DIR>/opencv/ffmpeg-download.ps1. The script should be run with administrative privileges if OpenVINO is installed in a system protected folder (this is a typical case). Alternatively, you can save results as images.
The demo outputs original video with the processed one. Usage:
Invert colors on the resulting frame by pressing the
Select a part of the frame to be shown in a separate window by using your left mouse button.
Exit the demo by pressing