Skip to content
harshmurikiPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ThirdEye - Intelligent Object Tracking System

ThirdEye (also known as VLMemory) is a comprehensive object detection and tracking system that combines Vision Language Models (VLM), YOLO object detection, and a persistent database to track and remember objects in real-time. Designed for household robotics and lost object tracking applications.

Project Links:

Features

  • Real-time Object Detection: Uses YOLO models for fast object detection from webcam feed
  • Vision Language Model (VLM) Integration: MLX-optimized VLM models for Apple Silicon with complex instruction following
  • Google Gemini Support: Alternative VLM processing using Google Gemini Live API
  • Persistent Object Database: SQLite database with VLM memory capabilities for tracking objects over time
  • REST API: FastAPI backend for frontend integration
  • WebSocket Support: Real-time image streaming from mobile devices
  • Apple Silicon Optimized: Native MLX support for M1/M2/M3 chips with GPU acceleration

Project Structure

ThirdEye/
├── vlm/                    # Vision Language Model implementations
│   ├── index_vlm_mlx_native.py  # MLX-optimized VLM (recommended for Apple Silicon)
│   ├── gemini_live_camera.py    # Google Gemini Live API integration
│   └── vlm_gui.py               # Modern GUI for object detection
├── database/               # Database and API
│   ├── database.py         # ObjectDatabase class with VLM memory
│   ├── api.py              # FastAPI REST API server
│   └── findobj.py         # Object search utilities
├── prompts/                # VLM prompt templates
│   ├── newItem.prompt     # Prompt for detecting new objects
│   └── existingItem.prompt # Prompt for identifying existing objects
├── archive/                # Legacy Node.js implementations
└── thirdeye.db            # SQLite database (created on first run)

Setup

Prerequisites

  • Python 3.8 or higher
  • Node.js v18 or higher (for legacy Node.js components)
  • A webcam connected to your computer
  • Apple Silicon Mac (M1/M2/M3) recommended for MLX acceleration

Installation

  1. Install Python dependencies:

    pip install -r requirements.txt
  2. Install Node.js dependencies (optional, for legacy components):

    npm install
  3. macOS users: Install imagesnap (required for webcam access):

    brew install imagesnap
  4. Set up environment variables:

Create a .env file in the project root:

GOOGLE_AI_API_KEY=your_google_ai_api_key_here

Usage

Running the VLM Object Detection (Recommended)

For Apple Silicon (MLX-optimized):

python vlm/index_vlm_mlx_native.py

For Google Gemini:

python vlm/gemini_live_camera.py

Running the Database API Server

Start the FastAPI server:

python database/api.py

The API will be available at http://localhost:8000

API documentation available at http://localhost:8000/docs

Running Legacy Node.js Components

npm start

How It Works

Object Detection Pipeline

  1. Frame Capture: Continuously captures frames from webcam or WebSocket stream
  2. YOLO Detection: Fast object detection using YOLO models (YOLOv8/YOLO11)
  3. VLM Processing: Vision Language Model analyzes detected objects with detailed attributes:
    • Object name, shape, material, brand, color, orientation
    • Spatial location and relationships to other objects
  4. Database Storage: Objects are stored with embeddings and metadata for future retrieval
  5. Memory System: VLM-powered memory system can identify previously seen objects

Database Schema

The ObjectDatabase stores objects with:

  • Basic attributes: name, shape, material, brand, color, orientation
  • Spatial information: local position description, global coordinates (latitude/longitude)
  • VLM descriptions: Rich natural language descriptions
  • Embeddings: Vector embeddings for semantic search
  • Timestamps: When objects were first seen and last updated

API Endpoints

  • GET /objects - List all tracked objects
  • GET /objects/{object_id} - Get specific object details
  • POST /objects - Add new object from image
  • POST /objects/search - Semantic search for objects
  • GET /objects/find - Find objects by attributes
  • POST /objects/{object_id}/update - Update object information

Model Information

YOLO Models

  • YOLOv8x: High accuracy, slower inference
  • YOLO11n: Fast, lightweight (default)
  • YOLO11m: Balanced performance

Models are automatically downloaded on first run.

VLM Models

MLX-Optimized (Apple Silicon):

  • mlx-community/Qwen2-VL-2B-Instruct-4bit - Recommended, 2B params, 4-bit quantized
  • Supports complex instruction following unlike basic BLIP models

Google Gemini:

  • gemini-2.5-flash-native-audio-preview-09-2025 - Via Google Gemini Live API

Apple Silicon GPU Acceleration

The application automatically detects Apple Silicon (M1/M2/M3) and uses GPU acceleration:

  • MLX Framework: Native MLX models for maximum performance
  • Metal/CoreML: Automatic GPU acceleration via ONNX Runtime
  • Benefits:
    • Faster inference times
    • Lower CPU usage
    • Better power efficiency
    • No configuration needed

WebSocket Integration

ThirdEye can receive images from mobile devices via WebSocket:

  1. Start the WebSocket server in ThirdEyeSensorLink/ (see ThirdEyeSensorLink README)
  2. Set USE_WEBSOCKET_IMAGE = True in the VLM script
  3. Images will be streamed in real-time from the mobile device

Dependencies

This project is part of a larger system with the following components:

Make sure to set up and run these components as needed for the full system functionality.

Requirements

  • Python 3.8+
  • Node.js v18+ (for legacy components)
  • Webcam or WebSocket image source
  • Internet connection (for first-time model downloads)
  • Google AI API key (for Gemini integration)

Notes

  • Models are downloaded on first run (may take several minutes)
  • Models run locally after initial download
  • Database file (thirdeye.db) is created automatically
  • Make sure your webcam is not being used by another application

Troubleshooting

macOS Users

  1. Install imagesnap: Required for webcam access

    brew install imagesnap
  2. Grant camera permissions:

    • System Preferences > Security & Privacy > Privacy > Camera
    • Grant permissions to Terminal/Python
  3. MLX-VLM not found:

    pip install mlx-vlm

Webcam Not Found

  • Ensure webcam is connected and not in use by another application
  • Try specifying a different camera index in the code
  • Check camera permissions in System Preferences

API Server Issues

  • Ensure port 8000 is not in use
  • Check that the database file exists and is writable
  • Verify all Python dependencies are installed

Performance Issues

  • Reduce image_width and image_height in performance config
  • Increase frame_skip to process fewer frames
  • Use smaller YOLO model (YOLO11n instead of YOLOv8x)
  • Ensure MLX acceleration is active on Apple Silicon

License

See LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages