matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.53k stars 11.68k forks source link

Running batch detections on Google Cloud ML #1272

Open NoahDolev opened 5 years ago

NoahDolev commented 5 years ago

Hi,

I am trying to deploy Mask RCNN to Google's Cloud ML Engine. I have managed to run the model in batch mode and collect the results of the output layers. However, ideally, I'd like to also compute the final mask as part of the job.

In other words, this part:

modelpath = model_list[0]
K.clear_session()
model = modellib.MaskRCNN(mode="inference", config=CellInferenceConfig(), model_dir=data_dir)

respath = "..path...to...cloud_output/"
resfiles = glob(respath+'prediction.results*')
resfiles = [r for r in resfiles if getsize(r)>0]
ishape = (1024, 1024, 3)
mshape = (2048, 2048, 3)
window = np.array([   0,    0, 2048, 2048])
final_masks=[]
for resfile in resfiles:
    json_data=open(resfile).read()
    data = json.loads(json_data)
    _, _, _, fm = model.unmold_detections(
                                np.asarray(data['mrcnn_detection/Reshape_1:0']), 
                                np.asarray(data['mrcnn_mask/Reshape_1:0']),
                                ishape, mshape, window)
    if (fm.shape[0]!=1024 or fm.shape[2]<1):
        print("Image Output Size Error")
    else: 
        final_masks.append(np.argmax(fm,2))   

I wonder whether anyone managed to accomplish this or has any ideas how to achieve it?

cairomo commented 5 years ago

how did you deploy? did you create a model resource on the ai platform or just ran it on a vm?

ajinkya933 commented 4 years ago

@NoahDolev can you give some pointers on how to solve this, also how you managed to change the output batch size ?