dynamic time so far warping utility
Project description
dtw-sofar
Overview
This library implements the "Dynamic Time Warping Algorithm" for multimodal research in a way it can warp the time series received "so far." In other words, it modifies the dynamic time warping algorithm to be compatible with 'iterative stimuli' (when future points in the time series are received one by one).
One motivating application is aligning natural language annotations and video frames for research on Visual Language Models (e.g. CLIP by OpenAI), when the latter's embeddings are received frame by frame (e.g. we're making observations and don't have access to future frames). With "dtw-sofar," we can predict optimally matching annotations to new video frames on the fly - by relying on temporal information available "so far."
Development and Contributions
For development details and contribution instructions, please refer to the contribution guidelines.
Installation:
First, install Python 3.7 (or later) and numpy, and then install this repo as a Python package.
$ pip install numpy
$ pip install dtw-sofar
Quick Start Examples:
Below is a sample use-case for quick start:
import importlib
import numpy as np
dtwsofar = importlib.import_module('dtw-sofar.dtw_sofar')
video_features = np.load('CLIP_video_embeddings_path')
text_features = np.load('CLIP_text_embeddings_path')
# iterates over each RGB frame's CLIP embeddings and classifies matching text embeddings on-the-fly:
final_path, dtw_matrix, onthefly_predictions, onthefly_path = dtwsofar.dtw_onthefly_classification(video_features, text_features)
This use case demonstrates performing dynamic time warping so-far on image and natural language embeddings from Open AI's CLIP Model, so as to align them. See the overview for relevance.
This library can also be used for simpler time-series:
# time-series to be aligned with dynamic time warping "so far":
time_series_a = np.random.rand(100, 1)
time_series_b = np.random.rand(35,1)
final_path, dtw_matrix, onthefly_alignment, onthefly_path = dtwsofar.dtw_onthefly_classification(time_series_a, time_series_b)
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
File details
Details for the file dtw-sofar-0.1.2.tar.gz
.
File metadata
- Download URL: dtw-sofar-0.1.2.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab5261a4746ae7ee6ffe36f8fb6afa2438bf4e9548b0f21b21b9e850ebc49b0d |
|
MD5 | 639351ae634b1feb63b5e1c7034baf20 |
|
BLAKE2b-256 | ec121ed32ba997bd8c2982744d5045e1f83161e6c816ac346fb2bec75298b4cd |
File details
Details for the file dtw_sofar-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: dtw_sofar-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 713636813231c38d580d7fc14bb1d7d17910a33f42c11c2008e85e6d0f82edf9 |
|
MD5 | 39489a3292827b8a2cc8c2f3515c144b |
|
BLAKE2b-256 | 976c027a4027ca49eedb86f9c2dd26b4d7a279818b2c896218b801038f063ad3 |