简体   繁体   中英

How to predict an image using .pkl file

I have trained an image classification model and saved it in.pkl file.
Now i don't know how to use that pickle file for single or multiple image prediction. I have done this for tabular data prediction but not for image

from sklearn.externals import joblib

classifer = joblib.load("model.pkl")

what to do next the method used for predicting tabular data is not working for image.

it should be the same, you read the image with whatever image module you're using, for example opencv:

import cv2 
img = cv2.imread('path/to/img')
classifier.predict(img)

if this doesn't work, maybe paste the error so it is easier to provide you with an answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM