roboflow / clip_video_app

Flask-based web application designed to compare text and image embeddings using the CLIP model.
22 stars 3 forks source link

CLIP Video Investigator

clip_video_investigator

Overview

CLIP Video Investigator is a Flask-based web application designed to compare text and image embeddings using the CLIP model. The application integrates OpenCV for video processing and Plotly for data visualization to accomplish the following:

  1. Play a video in a web browser.
  2. Pause and resume video playback.
  3. Compare CLIP embeddings of video frames with text embeddings.
  4. Visualize the similarity between text and image embeddings in real-time using a Plotly plot.
  5. Jump to specific frames by clicking on the Plotly plot.

Youtube video: https://www.youtube.com/watch?v=XllrtZnPL6M

Why This is Useful

Understanding the relationship between text and image embeddings can provide insights into how well a model generalizes across modalities. By plotting these values in real-time, researchers and engineers can:

Features

Configuration

A config.yaml file is used to specify various settings for the application:

roboflow_api_key: ""  # Roboflow API key
video_path: ""  # Path to video file
CLIP:
  - wall
  - tile wall
  - large tile wall

Folder Layout

clip_investigator/
├── config.yaml
├── scripts/
│   └── example.pkl
├── embeddings/
│   └── clip_app.py
│   └── clip_functions.py
├── static/
│   ├── css/
│   │   └── style.css
│   └── js/
│       └── main.js
└── templates/
    └── index.html

Installation

Prerequisites

Steps

  1. Clone the repository.

    git clone https://github.com/roboflow/clip_video_app.git
  2. Navigate to the project directory.

    cd  clip_video_app
  3. (Optional) Create a virtual environment.

  4. Install the dependencies.

    pip install -r requirements.txt

Usage

You must also be running the roboflow inference server localy!

  1. Update the config.yaml file with your Roboflow API key and the path to your video file (or use sample file in /data folder).

  2. Start the Flask application.

    python scripts/clip_app.py
  3. Open a web browser and navigate to http://localhost:5000.

  4. Use the "Start" and "Stop" buttons to control video playback.

  5. View real-time data related to the video in the Plotly plot below the video.

  6. Click on the Plotly plot to jump to specific video frames.

Troubleshooting