求大佬解答!!!!
centous服务器上搭建了flask框架的网站,在本地windows的CPU和GPU上均能正常运行。移植到服务器上在执行 preds = ssd_model.predict(photo)的时候会没有返回,调试发现在keras的training下卡在def _predict_loop里batch_outs = f(ins_batch)。移植了YOLO模型后会卡在另外的非项目文件。
加载了其他人的简单模型框架,可以正常运行,区别在卡死模型是load_weights,正常运行的是load_module。
可以运行:
def repredict(filename):
keras.backend.clear_session()
with CustomObjectScope({'relu6': relu6, 'DepthwiseConv2D': DepthwiseConv2D}):
model = load_model("./static/cats_dog_mobileNet.h5")
不可运行SSD:
def detect_image(self, image):
image_shape = np.array(np.shape(image)[0:2])
crop_img, x_offset, y_offset = letterbox_image(image, (self.model_image_size[0], self.model_image_size[1]))
photo = np.array(crop_img, dtype=np.float64)photo = preprocess_input(np.reshape(photo, [1, self.model_image_size[0], self.model_image_size[1], 3]))
with graph.as_default():
preds = self.ssd_model.predict(photo)#卡死
不可运行YOLO:
with graph.as_default():
out_boxes, out_scores, out_classes = self.sess.run(
[self.boxes, self.scores, self.classes],
feed_dict={
self.yolo_model.input: image_data,
self.input_image_shape: [image.size[1], image.size[0]],
# K.learning_phase(): 0
})
可以考虑使用Paddle Serving了。
https://github.com/PaddlePaddle/Serving
因为用centos来做深度学习的不多,我猜是不是调用了GPU?
看起来yolo和ssd正常跑都需要调用GPU,所以环境安装好了嘛?