ywflow / BubMask

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
33 stars 15 forks source link

Mask R-CNN for Bubble mask extraction

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:

The repository includes:

Mask Extraction Example

Tested environment

This code was tested on the below environment.

Preparing the input

Prepare images (JPG or PNG or TIF) under a series of folders ending in _###

How to test your own bubble image/video

  1. Clone this repository

  2. Install dependencies

    pip3 install -r requirements.txt
  3. Run setup from the repository root directory

    python3 setup.py install
  4. Download trained weights (mask_rcnn_bubble.h5) from the link.

  5. 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
  6. 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