erdogant / clustimage

clustimage is a python package for unsupervised clustering of images.
https://erdogant.github.io/clustimage
Other
92 stars 8 forks source link

Load the model #5

Closed MalekBezzina closed 2 years ago

MalekBezzina commented 2 years ago

Hello, i have ran and saved the model in a .pkl file and i have been trying to load it again. it says that it is loaded but i keep getting this error and i don't know how to fix it.

load

One more thing, if i succeed in loading the model, is it just for displaying the results? can't i run it again with another dataset hoping that it would recognize the shape that it had already clustered before ?

Thank you for your help!

erdogant commented 2 years ago

Without specifying a path, it stores the pickle file in the working directory. I'm not sure why it does not load correctly. However, I changed the saving directory to the default systems path. Maybe that helps. For your second questions, the models were not stored but now they are!

Update to the latest version.

pip install -U clustimage

This should work now:

from clustimage import Clustimage
# Init
cl = Clustimage(method='pca')
# load example with flowers
pathnames = cl.import_example(data='flowers')
# Cluster flowers
cl.fit_transform(pathnames)

cl.save(overwrite=True)
cl.load()

results_find = cl.find(pathnames[0:5], k=10, alpha=0.05)
cl.plot_find()

# Results are stored in:
print(cl.results)

# Parameters are stored in:
print(cl.params)
# Pickle file is saved to:
cl.params['filepath']
MalekBezzina commented 2 years ago

Thank you so much, now the saving and uploading of the file works perfectly well, I appreciate your support!

on a second note, what I am trying to achieve is to run the clustering model on dataset nb1 (let's say cats and dogs), save it, upload it and run it again on a second dataset (let's say cats, dogs and frogs).

I want it to be able to recognize the labels of the two first classes (which it had clustered before) so I only have to manually label the new class.

I found that the function "find() (clustimage.clustimage.Clustimage method)" might be helpful but I still don't know how to recover the labels!

I would appreciate your help!

erdogant commented 2 years ago

I added the label output in the results of the find functionality. update with: pip install -U clustimage

Check the documentation over here: https://erdogant.github.io/clustimage/pages/html/core_functions.html#find