[英]How to read and predict images outside the dataset using the knn algorithm
I have difficulty in an algorithm knn, how can I predict a new image outside of the dataset I'm using?我在算法 knn 上遇到困难,如何预测我正在使用的数据集之外的新图像? how is the coding?
编码如何?
I have difficulty in an algorithm knn, how can I predict a new image outside of the dataset I'm using?我在算法 knn 上遇到困难,如何预测我正在使用的数据集之外的新图像? how is the coding?
编码如何?
You can use this example code to to read your images.您可以使用此示例代码来读取图像。
from io import BytesIO
import numpy as np
import requests
from PIL import Image
response = requests.get(url)
img = Image.open(BytesIO(response.content))
img = np.array(img).reshape(1, -1)
output_class = neigh.predict(img)[0]
print(output_class)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.