Skip to main content

OpenCV for Semantic Video Understanding with Temporal Reasoning

Project description

👁️ Sharingan - Semantic Video Understanding

Sharingan GIF

Sharingan is a lightweight Python library for semantic video understanding with temporal reasoning. It combines vision-language models (CLIP, SmolVLM) with temporal analysis to understand video content at a deep semantic level.

Python 3.8+ License: MIT


✨ Features

  • 🎬 Semantic Video Processing – Understand video content beyond pixels
  • 🔍 Natural Language Queries – Search videos using text descriptions
  • 🤖 AI Chat – Conversational interface with Qwen2.5-0.5B
  • Temporal Reasoning – Cross-frame attention and memory tokens
  • 🎯 Event Detection – Automatically identify key moments
  • 💾 Efficient Storage – 130x compression with Int8 quantization
  • 🌐 Web UI – Beautiful Flask-based interface
  • 🚀 Fast Processing – Batch processing and GPU acceleration

You can read the Author Note, check out the Architecture, and see the Contributing Guidelines on GitHub.


🚀 Quick Start

Installation

pip install sharingan-core

# Optional: GPU acceleration
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118

# Optional: AI chat
pip install transformers bitsandbytes accelerate

Basic Usage

from sharingan import VideoProcessor

processor = VideoProcessor(
    vlm_model='clip',  # or 'smolvlm'
    device='auto'
)

results = processor.process('video.mp4')

matches = processor.query('person speaking')
for match in matches:
    print(f"Found at {match.timestamp}s - {match.confidence:.2%}")

response = processor.chat('What happens in this video?')
print(response)

Web UI

python -m sharingan.cli ui

Or programmatically:

from sharingan.ui import run_ui
run_ui(port=5000, open_browser=True)

📖 Documentation

Vision Models

  • CLIP – Fast semantic embeddings; memory ~400MB
  • SmolVLM-500M – Detailed frame descriptions; memory ~538MB (8-bit quantized)

Processing Options

processor = VideoProcessor(
    vlm_model='clip',
    device='auto',
    target_fps=5.0,
    enable_temporal=True,
    enable_tracking=False
)

Query Options

results = processor.query('person speaking', top_k=5)
response = processor.chat('Describe main events', use_llm=True)

🎯 Use Cases

  • Video Search – Find moments using natural language
  • Content Moderation – Detect inappropriate content
  • Video Summarization – Auto summaries
  • Accessibility – Descriptions for visually impaired
  • Research – Analyze video datasets at scale

🔧 Advanced Features

Temporal Reasoning

  • Cross-Frame Gating – Learns important frames
  • Memory Tokens – Maintains context across video
  • Temporal Attention – Understand relationships between frames

Efficient Storage

  • 5-min video: ~2.3MB (vs 300MB raw)
  • Fast cache loading
  • Minimal quality loss for search

Event Detection

  • Scene changes
  • Motion patterns
  • Content transitions

📊 Performance

Model Speed Memory Quality
CLIP ⚡⚡⚡ 400MB Good
SmolVLM ⚡⚡ 538MB Excellent

Tested on NVIDIA RTX 3050 (4GB VRAM)


🤝 Contributing

Contributions welcome! Please submit a PR.

📄 License

MIT License – see LICENSE file.

🙏 Acknowledgments

📧 Contact

Open an issue on GitHub for support.


Made with ☕ & ❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sharingan_core-3.0.0.tar.gz (66.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sharingan_core-3.0.0-py3-none-any.whl (69.8 kB view details)

Uploaded Python 3

File details

Details for the file sharingan_core-3.0.0.tar.gz.

File metadata

  • Download URL: sharingan_core-3.0.0.tar.gz
  • Upload date:
  • Size: 66.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for sharingan_core-3.0.0.tar.gz
Algorithm Hash digest
SHA256 94e43ab353efdbd4e5f8d5e226ff67ea8ce67794dcc798743a0d16673ae54739
MD5 62bc48e38e3524055982308765d4cb8f
BLAKE2b-256 940c49c09b778994c552144596e3cb0e2e7771b7ea79663c12d319d9f49f619d

See more details on using hashes here.

File details

Details for the file sharingan_core-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: sharingan_core-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 69.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for sharingan_core-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d09bfca1daef0dd7e1d63eded5b867ff5b51920942a37aeac085fc57f73e712
MD5 95564ef65c4a7864ee4bf17d3740543d
BLAKE2b-256 9a113503e6950857081b52da9a06dce99d0d7356e1e247dcd42080fcfba4a2e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page