Background Substitution using Python's OpenCV
Install requirements.
pip install -r requirements.txt
Experimentation may include the use of your own dataset. For verification, use the Supervisely Segmentation Sample Dataset and the WikiArt Dataset.
Run Single Backgorund Substitution Task on an Image and a desired Backgorund
python3 run.py <model> <image_file> <background_file> --blend_mode=<blend>
- model : Model of Image Segmentation ('contourmask', 'grabcut', 'watershed')
- image_file : Path to Image File (image.png)
- background_file : Path to Substitute Background File (background.png)
- (Optional) blend_mode : Image Blending Mode ( "gradient_mix", "balance", "hist_match_s", "hist_match_t", "none")
- (Optional) file_out : Output File (result.png)
Run an evaluation of the model for IoU and Pixel Accuracy metric
python3 run.py <model> <image_path> <mask_path> <background_path>
- model : Model of Image Segmentation ('contourmask', 'grabcut', 'watershed')
- image_path : Path to Images (images/)
- mask_path : Path to Ground Truth Masks (masks/)
- backgorund_file : Path to Substitute Background (background.png)