This project helps predicting segmentation masks of Human Body and hence changing background. I used 2 models for training: Unet with MobileNetV2 as a backbone and DeepLabV3p with MobileNetV2 as a backbone. Performance for both of the models on validation dataset trained for 45 epochs is given below:
Model | Precision | Recall | F1-score | IoU |
---|---|---|---|---|
Unet | 0.9195 | 0.8912 | 0.9044 | 0.8267 |
DeepLabV3p | 0.9069 | 0.9131 | 0.9095 | 0.8348 |
All various modes used for changing the background are mentioned below:
- 0: Picture in BG
- 1: Video in BG
- 2: Blurred Picture in BG
- 3: Blurred Video in BG
- 4: B/W Picture in BG
- 5: B/W Video in BG
Note: Whenever the keys (0, 1, 2, 3, 4, 5) are pressed, background modes will be changed, accordingly.
Original | Prediction | Overlay |
---|---|---|
![]() |
![]() |
![]() |
Original | Prediction | Overlay |
---|---|---|
![]() |
![]() |
![]() |
Predictions on webcam using Unet | Predictions on webcam using DeepLabV3p |
---|---|
![]() |
![]() |
- config.ini is the configuration file used to specify the parameters such as model_selection, prediction_type, input_file_path, BG_mode, and save_path.
- predict.py file contains code for prediction.
- utils.py file contains all helper functions for changing the background.
- Underwater.mp4 and bg.jpg are used for background.
- train folder training jupyter notebook for Unet and DeepLabV3p.
- Models folder contains .py files for Unet and DeepLabV3p along with their weights (.h5 file).
- predictions folder contains prediction of both models on random online images as well as videos taken live from Webcam.
- requirement.txt file contains all the required dependencies.
- Ensure that you are in the project home directory
- Create anaconda environment
- Activate environment
-
pip install -r requirement.txt
- set the parameters in the config.ini file
-
python init.py
- The credits for dataset used for training goes to https://www.kaggle.com/tapakah68/supervisely-filtered-segmentation-person-dataset
- I have referred https://github.com/bonlime/keras-deeplab-v3-plus/ repository for DeepLabV3p model.
- The credit for images and videos used for prediction and background goes to:
- https://thedigitalweekly.com/2021/07/06/black-widow-sequel-possible-says-director-cate-shortland/
- https://twitter.com/MarvelFansIT/status/1378680224922136576/photo/1
- https://twitter.com/carles_madness/status/1359549136480178182/photo/1
- Image by Pexels from Pixabay
- Video by Timofey Iasinskii from Pixabay