models icon indicating copy to clipboard operation
models copied to clipboard

Mask RCNN shows bounding boxes without mask after training

Open TheFlashover opened this issue 7 years ago • 1 comments

System information

  • What is the top-level directory of the model you are using: Object detection
  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): tf_record generated differently
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): b'v1.9.0-0-g25c197e023' 1.9.0
  • Bazel version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory: using Google Cloud
  • Exact command to reproduce:

tf_env.txt

Describe the problem

After packing the tfrecords and training in the Google Cloud tensorboard showed several masks with bounding boxes for the 0th step, but after some training, those masks disappeared remaining only the bounding boxes.

@pkulzc I'm asking for your advice on where to localize the issue. I have some guesses on this,

  1. This is because I used protobuf 3.6.0 for compiling on downloaded of latest tensorflow/models in order to create pycocotools, slim and object detection tar.gz files. And I'm using tensorflow of version 1.9 in my Google Cloud (so probably some discrepancy in compiled files and Google Cloud tensorflow version).

  1. I followed channel and pixel values part of the guide but It didn't work for me, so I tried different masks, both RGB and Single-channel with different PIL Modes.
  • RGB (PIL Mode: RGB): [0,0,0] - background, [255,255,255] - image mask.

  • Single channel (PIL Mode: L): 0 - background, 1 - image mask.

  • Single channel (PIL Mode: L): 2 - background, 3 - mask outline, 1 - mask itself (Exactly like PET dataset)

I changed the lines below in create_tf_pet_record.py when generated TFRecords to 0 - background, 1 - image mask, and similarly for all other different approaches:

nonbackground_indices_x = np.any(mask_np != 2, axis=0)
nonbackground_indices_y = np.any(mask_np != 2, axis=1)

to

nonbackground_indices_x = np.any(mask_np != 0, axis=0)
nonbackground_indices_y = np.any(mask_np != 0, axis=1)

to correspond the background value.

Single-channel is a (PIL Mode: L), am I right? I still don't know which one to use, the one in the guide or the one from PET dataset.

Or it might happen because i generated images from XML file which stored polygon coordinates using PIL instead of another Python library, so it might cause a problem converting the image to binary format.


  1. Instance segmentation masks can be supplied as serialized PNG images. image/object/mask = ["\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\...", ...]

let's say I have 2 PNG masks and they're stored in TFRecords like following:

features {
  feature {
    key: "image/object/mask"
    value {
      bytes_list {
        value:b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x05\x00\x00\x00\x02\xd0\x08\x00\ 
        x00\x00\x00\xea\x16\x82\x8a\x00\x00\r\x8bIDATx\x9c\xed\xdc\xcbn\x1c\xbb\x19\x85Q:\xef\
        xff\xce\...'

        value:b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x05\x00\x00\x00\x02\xd0\x08\x00\ 
        x00\x00\x00\xea\x16\x82\x8a\x00\x00\t\tIDATx\x9c\xed\xdc\xc1n\xe38\x10@A\x06\xd8\xff\xff\
        xe5\xeca\...'
      }
    }
  }
}

Is it correct? The string "supplied as serialized PNG images" confused me alot.


P.S. predict_instance_masks: true within the mask_rcnn_box_predictor in my mask_rcnn_*.config file and faces_only=False in create_tf_pet_record.py. P.P.S. I don't think it depends on the number of steps trained.

TheFlashover avatar Feb 27 '19 07:02 TheFlashover

It was due to insufficient amount of steps trained. Took more than 1000 steps for masks to show up.

TheFlashover avatar Mar 05 '19 04:03 TheFlashover