samedi 23 janvier 2021

Exporting Mask-RCNN (Tensorflow) to c++

i am new to this platform, any help or assistance would be highly highly appreciated.

I am working on a task of exporting my Mask-RCNN model (trained for rock detection) originally trained in python to be used in our robotic framework (which is built upon c++ and Java). To do this, i have the trained weights file (which i converted from .h5 to .pb) but when i tried to run a python script (just to visualize that .pb file), i am getting something which I honestly cannot understand What i actually want is the bounding box coordinates or mask coordinates.

x = graph.get_tensor_by_name('prefix/input_image:0') ## x = input image
y = graph.get_tensor_by_name('prefix/output_7:0')  ## y = output

after this , i open my image and reshape it

img = Image.open('asgdvd.jpg')

img = img.resize((1024,1024))
image = array(img).reshape(1,1024,1024,3)

after this, i try to see the predictions with this following code snipppet.

with tf.Session(graph=graph) as sess:


    pred_y = sess.run(y, feed_dict={x:image})
    print(pred_y)

what i recieve is this : [[[-0.44022697 0.9068849 -0.57112163 3.5229325 ] [-0.9684447 0.8227438 -0.3559094 0.98766834] [-0.9200943 -0.7196723 2.4025247 1.1918476 ] ... [ 0.30505624 -0.2963381 0.51927084 4.303519 ] [ 0.3955547 0.4455924 2.9750154 4.038637 ] [-0.026547 -0.07817449 2.7281873 2.9988997 ]]]

of the shape [1,261888,4]

what i think i have is the anchor boxes because when i do my demo object detection i get the same anchor box dimensions.

I am trying to follow this method: Import a simple Tensorflow frozen_model.pb file and make prediction in C++

Aucun commentaire:

Enregistrer un commentaire