Skip to content

jayrosen-design/animal-detector

Repository files navigation

DOI

WildSight

2nd Place Winner of Devpost GPT4o Code & Conquer AI Hackathon

WildSight Logo

Problem Statement

Wildlife-vehicle collisions are a major issue, resulting in:

  • Over 4,000 collisions every day in the United States.
  • Millions of animal deaths annually, costing $8.4 billion in damages.
  • 65% of surveyed drivers report witnessing or experiencing animal collisions.

WildSight offers an innovative, AI-powered solution to mitigate these risks and protect both wildlife and drivers.


How the AI Works

System Architecture Overview

flowchart TB
    subgraph Input["πŸ“· Image Input"]
        A[Upload Image] 
        B[Camera Capture]
    end
    
    subgraph Processing["🧠 AI Processing"]
        C[Load TensorFlow.js Model]
        D[Teachable Machine Model]
        E[Image Classification]
        F[Confidence Scoring]
    end
    
    subgraph Output["πŸ”Š Response System"]
        G{Confidence β‰₯ 50%?}
        H[Identify Animal Species]
        I[Lookup Audio Range]
        J{Confidence β‰₯ 75%?}
        K[Emit Ultrasonic Signal]
        L[Log Detection]
    end
    
    A --> C
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G
    G -->|Yes| H
    G -->|No| M[No Detection]
    H --> I
    I --> J
    J -->|Yes| K
    J -->|No| N[No Signal]
    K --> L
    N --> L
Loading

Detailed AI Pipeline

sequenceDiagram
    participant User
    participant UI as React UI
    participant TF as TensorFlow.js
    participant TM as Teachable Machine Model
    participant Audio as Audio System
    participant Log as Session Log

    User->>UI: Upload/Capture Image
    UI->>TF: Load Model (if not cached)
    TF->>TM: Fetch model.json & metadata.json
    TM-->>TF: Model Loaded
    UI->>TF: predictFromImage(image)
    TF->>TM: Run Inference
    TM-->>TF: Predictions Array
    TF->>TF: Find Best Prediction
    
    alt Confidence β‰₯ 50%
        TF-->>UI: Detection Result
        UI->>UI: Display Animal & Confidence
        
        alt Confidence β‰₯ 75%
            UI->>Audio: playFrequency(midRange)
            Audio->>Audio: Generate Oscillator
            Audio->>Audio: Map to Audible Range (200-2000 Hz)
            Audio-->>User: Play Deterrent Sound
        end
        
        UI->>Log: Add Detection Entry
    else Confidence < 50%
        TF-->>UI: No Detection
        UI-->>User: "No animal detected"
    end
Loading

Model Training Pipeline

flowchart LR
    subgraph Data["πŸ“Š Training Data"]
        A[("Kaggle Dataset 1<br/>90 Animal Species")]
        B[("Kaggle Dataset 2<br/>Cheetah/Tiger/Wolf")]
    end
    
    subgraph Training["πŸŽ“ Model Training"]
        C[Google Teachable Machine]
        D[Transfer Learning<br/>MobileNet Base]
        E[Custom Classification Layer]
    end
    
    subgraph Deployment["πŸš€ Deployment"]
        F[Export TensorFlow.js Model]
        G[Host on Google Cloud Storage]
        H[Load in Browser via tmImage]
    end
    
    A --> C
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G
    G --> H
Loading

Animal Classification Categories

The AI model is trained to recognize 8 animal categories commonly found near roads:

Animal Audio Range Frequency for Deterrent
🦌 Deer 2-5 kHz 3.5 kHz
🐿️ Squirrel 0.5-10 kHz 5.25 kHz
πŸ¦” Armadillo 1-4 kHz 2.5 kHz
🐭 Opossum 0.8-7 kHz 3.9 kHz
🐱 Cat 48-85 kHz 66.5 kHz
πŸ• Dog 45-67 kHz 56 kHz
🦝 Raccoon 0.3-8 kHz 4.15 kHz
🐰 Rabbit 5-10 kHz 7.5 kHz

Audio Signal Generation

flowchart TD
    A[Detection Result] --> B{Confidence β‰₯ 75%?}
    B -->|Yes| C[Get Audio Range for Species]
    B -->|No| D[No Signal Emitted]
    C --> E[Calculate Mid-Range Frequency]
    E --> F[Create Web Audio Context]
    F --> G[Create Oscillator Node]
    G --> H[Map kHz to Audible Hz<br/>Formula: 200 + freq-0.3/85-0.3 Γ— 1800]
    H --> I[Apply Gain Envelope<br/>Fade In β†’ Hold β†’ Fade Out]
    I --> J[Play for 3 seconds]
    J --> K[Stop Oscillator]
Loading

Technical Implementation Details

1. Model Loading

URL: https://storage.googleapis.com/tm-model/5UM9CXpEc/
Files: model.json, metadata.json
Library: @teachablemachine/image (tmImage)

2. Prediction Process

  1. Image is passed to model.predict()
  2. Returns array of predictions with className and probability
  3. Best prediction is selected using reduce() to find highest probability
  4. Threshold of 50% confidence required for valid detection

3. Audio Frequency Mapping

The system maps ultrasonic frequencies (0.3-85 kHz) to audible range (200-2000 Hz) for demonstration:

normalizedFreq = ((frequency - 0.3) / (85 - 0.3)) Γ— (2000 - 200) + 200

4. Detection Data Structure

interface Detection {
  timestamp: Date;      // When detection occurred
  animal: string;       // Classified animal name
  confidence: number;   // Prediction probability (0-1)
  audioRange: string;   // Species-specific frequency range
  imageUrl: string;     // Captured/uploaded image
}

Slides

Overview of WildSight

WildSight Slide 2
WildSight Slide 3
WildSight Slide 4
WildSight Slide 9

Key Features

  • AI Vision Technology: Detects wildlife in real time to prevent collisions.
  • Solar-Powered: Operates independently in remote areas.
  • Effective Frequencies: Emits specific sound frequencies to safely repel wildlife.
  • Weatherproof Design: Built for durability in all environments.
  • Sustainable and Serviceable: Environmentally friendly with minimal maintenance.

Prototypes


Technology Stack

flowchart TB
    subgraph Frontend["Frontend"]
        A[React 18]
        B[TypeScript]
        C[Vite]
        D[Tailwind CSS]
    end
    
    subgraph AI["AI/ML"]
        E[TensorFlow.js]
        F[Teachable Machine]
        G[MobileNet Transfer Learning]
    end
    
    subgraph Audio["Audio"]
        H[Web Audio API]
        I[Oscillator Nodes]
    end
    
    subgraph Data["Training Data"]
        J[Kaggle Datasets]
    end
    
    Frontend --> AI
    AI --> Audio
    J --> F
Loading

License

This project is licensed under DOI: 10.5281/zenodo.14739247.


"Saving lives, human and animal, shouldn't be optional."

About

AI ultrasonic emitter helps prevent wildlife-vehicle collisions.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages