Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

python - 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++

question from:https://stackoverflow.com/questions/65857659/exporting-mask-rcnn-tensorflow-to-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...