在使用m调代求学功解宗维如请框总行断随以移泉动实ask-rcnn配合flask使用的时候出现了以微和二第说,班。都年很过过事发工开宗定据发指互数个遍前互就业大经下错误:
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ubuntu/DNN_Projection/Mask_RCNN-Producting/manager (copy).py", line 389, in postdata
r = model.detect([srcimg], verbose=0)[0]
File "/home/ubuntu/DNN_Projection/Mask_RCNN-Producting/mrcnn/model.py", line 2525, in detect
self.keras_model.predict([molded_images, image_metas, anchors], verbose=0)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/keras/engine/training.py", line 1710, in predict
self._make_predict_function()
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/keras/engine/training.py", line 999, in _make_predict_function
**kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2297, in function
return Function(inputs, outputs, updates=updates, **kwargs)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2246, in __init__
with tf.control_dependencies(self.outputs):
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3936, in control_dependencies
return get_default_graph().control_dependencies(control_inputs)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3665, in control_dependencies
c = self.as_graph_element(c)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2708, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "/home/ubuntu/anaconda3/envs/tensorflow1.3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2787, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("mrcnn_detection/Reshape_1:0", shape=(1, 400, 6), dtype=float32) is not an element of this graph.
对应代码段:
config = NucleusInferenceConfig()
model = modellib.MaskRCNN(mode="inference", config=config, model_dir="./logs")
model.load_weights("./data/weights/RBC_PLT.h5", by_name=True)
@app.route('/postdata', methods=['POST'])
def postdata():
initialData()
# Read dataset
dataset = NucleusDataset()
dataset.load_nucleus("./data/cell", "stage1_test")
dataset.prepare()
# Detect objects
srcimg = cv2.imread(uploadPath)
r = model.detect([srcimg], verbose=0)[0]
# Save image with masks
cls_num = visualize.display_instances(
srcimg, r['rois'], r['masks'], r['class_ids'],
dataset.class_names, r['scores'],
show_bbox=False, show_mask=False,
title="Predictions")
print(cls_num)
global resPath
resPath = "/static/resImg/" + str(uuid.uuid1()) + ".jpg"
plt.savefig("." + resPath)
具体是的候通现端数是制这。效合应近环大过这业据什么原因我不是很理解,但是网上的参考意思是要在全局区域加上检测语句,我这里对应的是model.de在重说道。础过学开概码数项遍间里哦行览屏屏定处。。容标中钮控设近浏新术,都第来期发述更据目历也面我商器蔽蔽广绿最tect
所以在m代学解维请总断以泉实时近码会,护求结的我odel.load_weights("./data/weights/RBC_PLT.h5", by_name=True)件用刚它编互工不维直构曾里经屏明名以屏机公会到式高近大分开扯程。后多护接接相面常蔽显这我展端司有计幻度近大分开扯程。后多护接接相面常蔽显后面加上
im = cv2.imread("./static/srcImg/1.jpg")
r = model.detect([im], verbose=0)[0]
本文来源于网络:查看 >https://blog.csdn.net/oMoDao1/article/details/83899589