Closed saikovvuri closed 3 months ago
Hello ,
Is it possible to sort the items in an array of DistancesTensors.
-- using uform pre-trained model from uform import get_model, Modality
processors, models = get_model('unum-cloud/uform3-image-text-english-small')
model_text = models[Modality.TEXT_ENCODER] model_image = models[Modality.IMAGE_ENCODER] processor_text = processors[Modality.TEXT_ENCODER] processor_image = processors[Modality.IMAGE_ENCODER]
-- get input text and image text = 'some text' image_url = 'https://media-cdn.tripadvisor.com/media/photo-s/1b/28/6b/53/lovely-armenia.jpg' image = Image.open(BytesIO(requests.get(image_url).content))
-- text embedding text_data = processor_text(text) text_features, text_embedding = model_text.encode(text_data, return_features=True)
-- image embedding image_data = processor_image(image) image_features, image_embedding = model_image.encode(image_data, return_features=True)
sim = cosine(image_embedding, text_embedding)
-- add sim to a an array
Hi @saikovvuri! Can you please clarify the question?
Hello ,
Is it possible to sort the items in an array of DistancesTensors.
-- using uform pre-trained model from uform import get_model, Modality
processors, models = get_model('unum-cloud/uform3-image-text-english-small')
model_text = models[Modality.TEXT_ENCODER] model_image = models[Modality.IMAGE_ENCODER] processor_text = processors[Modality.TEXT_ENCODER] processor_image = processors[Modality.IMAGE_ENCODER]
-- get input text and image text = 'some text' image_url = 'https://media-cdn.tripadvisor.com/media/photo-s/1b/28/6b/53/lovely-armenia.jpg' image = Image.open(BytesIO(requests.get(image_url).content))
-- text embedding text_data = processor_text(text) text_features, text_embedding = model_text.encode(text_data, return_features=True)
-- image embedding image_data = processor_image(image) image_features, image_embedding = model_image.encode(image_data, return_features=True)
sim = cosine(image_embedding, text_embedding)
-- add sim to a an array