This is a project of Multiphase flow & Flow visualization Lab for bubble detection and mask extraction. The purpose of the project is to automatically extract bubble mask of experimental images from various experimental conditions using deep learning model. More information can be found in the paper (Kim & Park, 2021).
The codes are based on Matterport Mask R-CNN implementation, using ResNet-101 as the backbone and applied transfer learning from pre-trained COCO weights.
The output of the model is as follows:
- color mask for input image/video
- PNG logical mask for each bubble detected
- bubble property txt (centroid, area, axes, orientation)
The repository includes:
- Source code of Mask R-CNN built on FPN and ResNet101.
- Source code to visualize the color mask of the input image/video.
- source code to detect and save logical mask and bubble properties.
This code was tested on the below environment.
- NVIDIA RTX 2080 ti
- Driver 440.95.01
- CUDA 10.2
- cuDNN 7.6.5
- Python 3.7
- TensorFlow 1.14.0
- Keras 2.2.5 and other common packages listed in
requirements.txt
.
Prepare images (JPG or PNG or TIF) under a series of folders ending in _###
- For example,
folder_001, folder_002 ...
- Your
path/to/image
become.../folder
-
Clone this repository
-
Install dependencies
pip3 install -r requirements.txt
-
Run setup from the repository root directory
python3 setup.py install
-
Download trained weights (mask_rcnn_bubble.h5) from the link.
-
Run bubble detection script in
bubble/
directory to visualize color mask (supports only 3-channel jpg image or video)bubble$ python3 bubble.py splash --weights=path/to/mask_rcnn_bubble.h5 --image=path/to/image
for the video:
bubble$ python3 bubble.py splash --weights=path/to/mask_rcnn_bubble.h5 --video=path/to/video
-
Run bubble detection script in
bubble/
directory to extract logical mask and bubble properties (JPG or PNG or TIF images)bubble$ python3 bubble.py detect --weights=path/to/mask_rcnn_bubble.h5 --image=path/to/image --results=/path/to/results --folder_num_start=0 --folder_num=1 --confidence=0.5 to 0.99