Closed sandkoan closed 1 year ago
Hello. We didn't try to export the uform model as CoreML model, but if you did it, we would love to see
Ahh, okay. Is there currently a way to batch embed these images/texts at once as opposed to in individual function calls?
Yes. First of all, you need to make the batch of preprocessed texts and images:
batch_texts = model.preprocess_text(['cat', 'dog'])
images = [Image.open('cat.jpg'), Image.open('dog.jpg')]
batch_images = []
for image in images:
batch_images.append(model.preprocess_image(image))
batch_images = torch.stack(batch_images, dim=0)
Then, you can use encode_text
and encode_image
:
text_embeddings = model.encode_text(batch_texts) # 2 x embedding_dim
image_embeddings = model.encode_image(batch_images) # 2 x embedding_dim
So preprocess_text
can accept a list, and the preprocess_image
can't? If so, @kimihailv should we change that?
Have y'all experimented with exporting the uform model (which is fantastic, by the way) as a CoreML model, so it can be run on-device more efficiently?