Views
No views yet
pip install sportsvision1import torch
2from sportsvision.research.configs import UnifiedEmbedderConfig
3from sportsvision.research.models import UnifiedEmbedderModel
4from transformers import AutoConfig, AutoModel
5from PIL import Image
6
7# Register the custom configuration and model
8AutoConfig.register("unified_embedder", UnifiedEmbedderConfig)
9AutoModel.register(UnifiedEmbedderConfig, UnifiedEmbedderModel)
10
11# Initialize the model from the pretrained repository
12emb_model = AutoModel.from_pretrained("sportsvision/omniemb-v1")
13
14# Determine the device
15device = "cuda" if torch.cuda.is_available() else "cpu"
16
17# Move the model to the device
18emb_model = emb_model.to(device)
19
20# Set the model to evaluation mode
21emb_model.eval()
22
23# Sample texts
24texts = [
25 "Playoff season is exciting!",
26 "Injury updates for the team."
27]
28
29# Encode texts to obtain embeddings
30text_embeddings = emb_model.encode_texts(texts)
31print("Text Embeddings:", text_embeddings)
32
33# Sample images
34image_paths = [
35 "path_to_image1.jpg",
36 "path_to_image2.jpg"
37]
38
39# Load images using PIL
40images = [Image.open(img_path).convert('RGB') for img_path in image_paths]
41
42# Encode images to obtain embeddings
43image_embeddings = emb_model.encode_images(images)
44print("Image Embeddings:", image_embeddings)1@misc{kodathala2024omniemb,
2 author = {Kodathala, Varun},
3 title = {OmniEmb-v1: Multi-Modal Embeddings for Unified Retrieval},
4 year = {2024},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/sportsvision/omniemb-v1}}
7}