使用keras 加载mobilenet模型来对图片进行预测

from tensorflow.keras.applications.mobilenet import MobileNet
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.mobilenet import preprocess_input
import numpy as np
import cv2 as cv

model = MobileNet(weights=imagenet, include_top=False)



img_path = sample1/1.png
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

features = model.predict(x)
model.summary()
print(features.shape)

 

使用keras 加载mobilenet模型来对图片进行预测

上一篇:【613】U-Net 相关


下一篇:JS如何实现无缝切换轮播图