Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‘οΈ VisionMate - Universal Scene Understanding Assistant

Python 3.9+ PyTorch 2.0+ License: MIT

An innovative computer vision project combining SAM 2, Depth Anything V2, and CLIP for comprehensive scene understanding.

VisionMate Demo

🎯 What is VisionMate?

VisionMate is a cutting-edge AI system that can:

  • 🎯 Segment any object in an image (click to identify)
  • πŸ“ Estimate depth (how far away is each object?)
  • 🧠 Understand language (ask questions about the scene)
  • πŸ’¬ Answer queries ("What is the closest object?")

The Innovation

VisionMate fuses three state-of-the-art models from 2024-2025:

Model What it does Released
SAM 2 Universal object segmentation July 2024
Depth Anything V2 Monocular depth estimation NeurIPS 2024
CLIP Vision-language understanding 2021

This combination enables spatial reasoning that no single model can achieve:

  • "What is the closest object?" β†’ Uses SAM + Depth
  • "Where is the person?" β†’ Uses SAM + CLIP + position
  • "Describe the scene" β†’ Uses all three!

πŸš€ Quick Start

1. Clone and Setup

git clone https://github.com/yourusername/VisionMate.git
cd VisionMate

# Create virtual environment
python -m venv venv

# Activate it
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

2. Run the Demo

python app.py

Open your browser to http://127.0.0.1:7860

3. First Use

On first run, models will be downloaded (~2GB total). This only happens once!


πŸ’» Usage

Web Interface

The Gradio demo provides:

  • Upload & Analyze: Upload any image for full scene analysis
  • Depth Map: Visualize distances with color coding
  • Q&A: Ask natural language questions
  • Click to Identify: Click any point to identify the object

Python API

from visionmate import VisionMate

# Initialize (loads models)
vm = VisionMate()

# Analyze an image
scene = vm.analyze("photo.jpg")

# Ask questions
print(vm.query(question="What do you see?"))
print(vm.query(question="What is the closest object?"))

# Interactive segmentation
result = vm.segment_at_point("photo.jpg", x=100, y=200)
print(f"You clicked on: {result['label']}")
print(f"Distance: {result['depth']['mean_distance']:.2f}")

# Get depth map
depth, colormap = vm.get_depth_map("photo.jpg", colormap=True)

πŸ“– How It Works

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        VisionMate Pipeline                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                  β”‚
β”‚   πŸ“· Image                                                       β”‚
β”‚      β”‚                                                           β”‚
β”‚      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚
β”‚      β–Ό                  β–Ό                  β–Ό                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚  β”‚ SAM 2  β”‚        β”‚ Depth  β”‚        β”‚  CLIP  β”‚                β”‚
β”‚  β”‚ (Seg)  β”‚        β”‚Anythingβ”‚        β”‚ (VLM)  β”‚                β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜                β”‚
β”‚       β”‚                 β”‚                  β”‚                    β”‚
β”‚       β–Ό                 β–Ό                  β–Ό                    β”‚
β”‚   [Masks]           [Depth Map]       [Labels]                  β”‚
β”‚       β”‚                 β”‚                  β”‚                    β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
β”‚                         β–Ό                                       β”‚
β”‚                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                               β”‚
β”‚                 β”‚   Spatial     β”‚                               β”‚
β”‚                 β”‚   Reasoner    β”‚                               β”‚
β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                               β”‚
β”‚                         β–Ό                                       β”‚
β”‚                 πŸ’¬ Natural Language Answer                       β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Concepts Demonstrated

  1. Foundation Models: Using pre-trained models for zero-shot generalization
  2. Multi-Modal AI: Fusing vision and language understanding
  3. Model Orchestration: Combining multiple models into a pipeline
  4. Spatial Reasoning: Deriving 3D understanding from 2D images

πŸŽ“ Learning Resources

Each file contains detailed comments explaining:

File Concepts Covered
depth_estimator.py Monocular depth estimation, Vision Transformers, lazy loading
segmenter.py Foundation models, promptable AI, IoU metrics
vision_language.py CLIP, contrastive learning, embeddings, zero-shot classification
spatial_reasoner.py Model fusion, scene graphs, spatial relationships
pipeline.py Facade pattern, API design, memory management
app.py Gradio, web interfaces, event handling

πŸ“Š Performance

Tested on NVIDIA RTX 3050 (6GB VRAM):

Operation Time
First load ~30s (downloads models)
Analyze image ~3-5s
Answer query ~0.1s
Click segmentation ~0.5s

πŸ› οΈ Configuration

Adjust model sizes for speed/quality trade-off:

# Fast (lower quality) - good for demos
vm = VisionMate(
    depth_model="small",
    seg_model="tiny",
    vlm_model="base",
)

# Balanced
vm = VisionMate(
    depth_model="base",
    seg_model="small",
    vlm_model="base",
)

# High quality (slower, needs more VRAM)
vm = VisionMate(
    depth_model="large",
    seg_model="large",
    vlm_model="large",
)

πŸ“ Project Structure

VisionMate/
β”œβ”€β”€ visionmate/
β”‚   β”œβ”€β”€ __init__.py           # Package exports
β”‚   β”œβ”€β”€ depth_estimator.py    # Depth Anything V2 wrapper
β”‚   β”œβ”€β”€ segmenter.py          # SAM 2 wrapper
β”‚   β”œβ”€β”€ vision_language.py    # CLIP wrapper
β”‚   β”œβ”€β”€ spatial_reasoner.py   # Fusion & reasoning
β”‚   └── pipeline.py           # Main VisionMate class
β”œβ”€β”€ app.py                    # Gradio web interface
β”œβ”€β”€ requirements.txt          # Python dependencies
└── README.md                 # This file

🀝 Contributing

Contributions welcome! Ideas for extensions:

  • Video support (use SAM 2's video capabilities)
  • Metric depth estimation (convert relative to absolute)
  • More query types (counting, OCR, attributes)
  • Voice input/output
  • Mobile optimization

πŸ“„ License

MIT License - feel free to use for your portfolio!


πŸ™ Acknowledgments


Built for learning and portfolio demonstration
⭐ Star this repo if you found it helpful!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages