Sports Vision Research Tools
Project description
Sports Vision
Sports Vision is a suite of research tools designed to advance computer vision applications in sports analytics. Developed with passion, this toolkit provides unified embeddings for both text and image data, enabling comprehensive multi-modal analysis.
Features
- Text Embeddings: Generate high-quality text representations
- Image Embeddings: Extract meaningful features from images
- Multi-Modal Embeddings: Combine text and image data for holistic analysis
- Unified Embeddings: Consistent embedding space for diverse data types
Installation
Install the package via PyPI using pip:
pip install sportsvision
Note: Ensure you have the appropriate version of PyTorch installed. Visit the official PyTorch website for installation instructions tailored to your system and CUDA version.
Usage
Here's a step-by-step guide to using the sportsvision package for encoding texts and images.
1. Import Required Libraries
import torch
from sportsvision.research.configs import UnifiedEmbedderConfig
from sportsvision.research.models import UnifiedEmbedderModel
from transformers import AutoConfig, AutoModel
from PIL import Image
2. Register Custom Config and Model with Transformers
To integrate the custom UnifiedEmbedderConfig and UnifiedEmbedderModel with Hugging Face's transformers library:
# Register the custom configuration and model
AutoConfig.register("unified_embedder", UnifiedEmbedderConfig)
AutoModel.register(UnifiedEmbedderConfig, UnifiedEmbedderModel)
3. Load the Pretrained Model
Load the pretrained UnifiedEmbedderModel from the Hugging Face Hub:
# Initialize the model from the pretrained repository
emb_model = AutoModel.from_pretrained("sportsvision/omniemb-v1")
4. Prepare the Model for Inference
# Determine the device
device = "cuda" if torch.cuda.is_available() else "cpu"
# Move the model to the device
emb_model = emb_model.to(device)
# Set the model to evaluation mode
emb_model.eval()
5. Encode Texts
# Sample texts
texts = [
"Playoff season is exciting!",
"Injury updates for the team."
]
# Encode texts to obtain embeddings
text_embeddings = emb_model.encode_texts(texts)
print("Text Embeddings:", text_embeddings)
6. Encode Images
# Sample images
image_paths = [
"path_to_image1.jpg",
"path_to_image2.jpg"
]
# Load images using PIL
images = [Image.open(img_path).convert('RGB') for img_path in image_paths]
# Encode images to obtain embeddings
image_embeddings = emb_model.encode_images(images)
print("Image Embeddings:", image_embeddings)
Complete Example
Here's a comprehensive example combining all the steps above:
import torch
from sportsvision.research.configs import UnifiedEmbedderConfig
from sportsvision.research.models import UnifiedEmbedderModel
from transformers import AutoConfig, AutoModel
from PIL import Image
# Register the custom configuration and model
AutoConfig.register("unified_embedder", UnifiedEmbedderConfig)
AutoModel.register(UnifiedEmbedderConfig, UnifiedEmbedderModel)
# Initialize the model from the pretrained repository
emb_model = AutoModel.from_pretrained("sportsvision/omniemb-v1")
# Determine the device
device = "cuda" if torch.cuda.is_available() else "cpu"
# Move the model to the device
emb_model = emb_model.to(device)
# Set the model to evaluation mode
emb_model.eval()
# Sample texts
texts = [
"Playoff season is exciting!",
"Injury updates for the team."
]
# Encode texts to obtain embeddings
text_embeddings = emb_model.encode_texts(texts)
print("Text Embeddings:", text_embeddings)
# Sample images
image_paths = [
"path_to_image1.jpg",
"path_to_image2.jpg"
]
# Load images using PIL
images = [Image.open(img_path).convert('RGB') for img_path in image_paths]
# Encode images to obtain embeddings
image_embeddings = emb_model.encode_images(images)
print("Image Embeddings:", image_embeddings)
Documentation
For more detailed information, tutorials, and advanced usage, please visit our Hugging Face Documentation.
License
This project is licensed under the MIT License.
Contact
For any questions or feedback, please contact Varun Kodathala (varun@sportsvision.ai).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sportsvision-0.1.0.tar.gz.
File metadata
- Download URL: sportsvision-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c48bc98b708039f4b43833887616eeff6bd05b95e67554fb8f13065d81ec740c
|
|
| MD5 |
a1db8fa4b30e4a844169b6b64c8e1bd9
|
|
| BLAKE2b-256 |
81e26bae543ee240f2e0b119c6edde8f8be1a5471a680dbd54ab476ae0f726a0
|
File details
Details for the file sportsvision-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sportsvision-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52b9c84ae6110b98b247f3c41544b1efa51156c5b1c8b04dca3d3f456e733ab3
|
|
| MD5 |
ce42bccc88ae77d5ab1d755d5aec214e
|
|
| BLAKE2b-256 |
bf81c551607261e1db1f3fcbe0bc10b3a01a75aaa74ffea57aa5f29c66b1f2c6
|