简体   繁体   English

如何使用knn算法读取和预测数据集外的图像

[英]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.

相关问题 训练KNN分类器后如何预测特定图像(来自数据集或来自外部数据集) - How to predict a specific Image (from or outside dataset) after training the KNN classifier 训练后如何使用带有 keras 的 VGG16 预测图像(外部数据集)? - How can i predict images(outside dataset) using VGG16 with keras after training? CNN Model 无法预测数据集外的图像(FaceMask Detection) - CNN Model can't predict images outside the dataset (FaceMask Detection) 如何使用 sklearn KNN 预测值 - How to predict values with sklearn KNN 如何使用分割图像数据集从 predict_generator 输出中生成分类报告和混淆矩阵? (Keras Tensorflow) - How to do a classification_report and a confusion_matrix from the predict_generator output using a segmentation images dataset ? ( Keras Tensorflow) 在熊猫中使用KNN算法进行正向选择 - Forward Selection using KNN Algorithm in Pandas 为什么我不能使用SVM和KNN预测新数据? - Why can't I predict new data using SVM and KNN? 使用中位数(而非均值)预测sklearn-KN​​N - Predict with sklearn-KNN using median (instead of mean) 我该如何改进这个 knn 算法? - How can i improve this knn algorithm? 如何将模型输入到 KNN 分类算法中? - how to input the model into the KNN classification algorithm?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM