You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To follow-up #16 and the discussion in bioclip, create an option for the text embeddings cache to be saved to disk and an option to load these from a specified filepath rather than recomputing if the category list is reused.
The text was updated successfully, but these errors were encountered:
This can be somewhat done with the current code, but it isn't very appealing. The CustomLabelsClassifier class has two properties that contain the embeddings. classes - a list of class names and txt_features. Both of these items would need to be saved and restored.
Rough Code
Embed text an save "classes.json" and "txt_features.npy":
from bioclip import CustomLabelsClassifier
import numpy as np
import json
classifier = CustomLabelsClassifier(cls_ary=["dog","cat","fish"])
with open("classes.json", "w") as outfile:
json.dump(classifier.classes, outfile)
np.save("txt_features.npy", classifier.txt_features.numpy())
Load "classes.json" and "txt_features.npy" and make a prediction:
from bioclip import CustomLabelsClassifier
import numpy as np
import json
classifier = CustomLabelsClassifier(cls_ary=[""])
with open("classes.json", "r") as infile:
classifier.classes = json.load(infile)
classifier.txt_features = np.load("txt_features.npy")
print(classifier.predict("Ursus-arctos.jpeg"))
Adds method to CustomLabelsClassifier to save class labels and
embeddings to a npy file. Adds embeddings_path parameter to
CustomLabelsClassifier to load the labels and embeddings.
This change needs to wait for this PR due to a field name change:
#64Fixes#17
To follow-up #16 and the discussion in bioclip, create an option for the text embeddings cache to be saved to disk and an option to load these from a specified filepath rather than recomputing if the category list is reused.
The text was updated successfully, but these errors were encountered: