【发布时间】:2018-07-30 06:32:39
【问题描述】:
我正在尝试使用 keras fune-tuning 来开发图像分类应用程序。 我将该应用程序部署到 Web 服务器,图像分类成功。
但是,当同时从两台或多台计算机上使用该应用程序时,会出现以下错误消息并且该应用程序无法运行。
TypeError:无法将 feed_dict 键解释为 Tensor:Tensor Tensor("Placeholder:0", shape=(3, 3, 3, 64), dtype=float32) 不是此图的元素。
这是我的图像分类代码。
img_height, img_width = 224, 224
channels = 3
input_tensor = Input(shape=(img_height, img_width, channels))
vgg19 = VGG19(include_top=False, weights='imagenet', input_tensor=input_tensor)
fc = Sequential()
fc.add(Flatten(input_shape=vgg19.output_shape[1:]))
fc.add(Dense(256, activation='relu'))
fc.add(Dropout(0.5))
fc.add(Dense(3, activation='softmax'))
model = Model(inputs=vgg19.input, outputs=fc(vgg19.output))
model.load_weights({h5_file_path})
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
img = image.load_img({image_file_path}, target_size=(img_height, img_width))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = x / 255.0
pred = model.predict(x)[0]
如何在多台计算机上同时运行此应用程序?
感谢您阅读这篇文章。
【问题讨论】:
-
@Mitiku 非常感谢!这一定是我想要的信息。我试试看。
标签: python tensorflow keras