【发布时间】:2019-12-04 19:14:12
【问题描述】:
我想从图像 URL 中检索图像并将它们输入 keras 中的 CNN 模型,但我不想将图像存储在本地文件夹中?
有没有办法做到这一点?
【问题讨论】:
标签: deep-learning computer-vision conv-neural-network
我想从图像 URL 中检索图像并将它们输入 keras 中的 CNN 模型,但我不想将图像存储在本地文件夹中?
有没有办法做到这一点?
【问题讨论】:
标签: deep-learning computer-vision conv-neural-network
您可以使用 skimage.io 从 URL 读取图像。阅读后,您应该展开数组。例如:图像阵列形状为 (64,64,3)。展开后(1,64,64,3)
from skimage import io
import tensorflow as tf
#Load model
model = tf.load_model("model.h5")
# Read image from web image
image_array = io.imread('https://i.stack.imgur.com/QupKb.png')
img_array = tf.expand_dims(img_array, 0)
predictions = model.predict(img_array)
【讨论】:
您可以使用skimage 从这样的图像 URL 中读取图像
from skimage import io
import cv2
# Read image from web image
image = io.imread('https://i.stack.imgur.com/QupKb.png')
# Display image
cv2.imshow('image', image)
cv2.waitKey()
【讨论】: