-
-
Save jurand71/989d64a50809ff8a7d7e1a45bcfdc9d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Klasyfikacja obrazu odpadu") | |
img = cv2.imread("VAL/O/O_14000.jpg") | |
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
img_pred = cv2.resize(img, (81, 81), interpolation=cv2.INTER_AREA) | |
img_pred = img_to_array(img_pred) | |
img_pred = img_pred/255 | |
img_pred = np.reshape(img_pred, (1, img_pred.shape[0]*img_pred.shape[1])) | |
# Trenujemy klasyfikator | |
classifier2 = KNearestNeighbor() | |
classifier2.train(X_train, y_train) | |
dists2 = classifier2.compute_distances_no_loops(img_pred) | |
# Prognozujemy kategorię obrazu przy określonym k | |
y_test_pred = classifier2.predict_labels(dists2, k=76) | |
# Określenie rodzaju | |
labels = ["Organic", "Recyclable"] | |
print(labels[int(y_test_pred)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment