Currently The K-means CLustring code is written like this in a method:
def predict(image_path):
image = cv2.imread(image_path)
image = image.reshape((image.shape[0] * image.shape[1], 3))
clt = KMeans(n_clusters = 3, random_state=2, n_jobs=1)
clt.fit(image)
How can I save This to a model so I can convert it to Core-ML and use it in my application?
Save:
pickle.dump(clt, open("save.pkl", "wb"))
Load:
clt = pickle.load(open("save.pkl", "rb"))
Core ML does not support K-means clustering at the moment.
You can find a simple implementation of K-means at the Swift Algorithm Club .
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.