Skip to content

PolnareffTurtle/ad-intelligence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š AdSmart - Intelligent Advertisement Feature Extraction

Calhacks 12.0 Submission

AdSmart is a comprehensive web application that leverages computer vision, audio analysis, and generative AI to provide actionable insights on advertisement performance. Upload your image or video ads and receive instant, data-driven feedback on key metrics that influence audience engagement.


๐ŸŽฏ Problem Statement

Modern advertisers struggle to quantify what makes an ad effective. Traditional A/B testing is expensive and time-consuming. AdMetrics AI solves this by providing instant, objective analysis of ad creative elements before launch, helping marketers optimize their content for maximum impact.


๐Ÿ“Š Signals Explained

Image Signals

Metric Range Description
Color Contrast 0.0 - 1.0 Measures visual distinction and readability
Product Size Ratio 0.0 - 1.0 Product prominence (0=small, 1=large)
Text Number Int Answers the question: How many words appear on the ad?
Negative Space Ratio 0.0 - 1.0 White space for visual breathing room
Product Name String Answers the question: What product is being sold?
External Buttons List Detected CTA text elements
Human Features List Detected human characteristics
Appeal String Explains the appeal of product

Video Signals

Metric Range Description
Scene Count Integer Number of distinct scenes/cuts
Dimensions Float Ratio of width/length
Product Name String Answers the question: What is the name of the product?
Human Features List Detected human characteristics
Sound Peaks dB/10s Number of significant peaks
Speech Coverage 0.0 - 100% Voice-over percentage
Music Coverage 0.0 - 100% Music-over percentage
Time Until First Significant Peak seconds When the first significant sound change is created (whether music or speech)

๐ŸŽจ User Experience

  • Batch Upload Support - Analyze multiple ads simultaneously
  • Persistent Media Library - View and re-analyze historical uploads
  • Real-time Processing - Instant feedback with progress indicators
  • Responsive Design - Works seamlessly on desktop and mobile
  • Exportable Results - Download full analysis as JSON

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Streamlit - Rapid web app development with Python
  • Custom CSS - Polished, professional UI/UX

Computer Vision & Image Processing

  • OpenCV (cv2) - Advanced image and video analysis
  • PIL/Pillow - Image manipulation and format conversion
  • NumPy - Efficient numerical computations

AI & Machine Learning

  • Google Gemini 2.5 Flash - State-of-the-art multimodal AI for product detection and feature recognition
  • Pydantic - Structured data validation and schema enforcement

Audio Processing

  • FFmpeg - Audio extraction and conversion
  • Custom Audio Analysis Pipeline - Peak detection, voice analysis, and music classification

Backend

  • Python 3.8+ - Core application logic
  • python-dotenv - Secure environment variable management
  • Tempfile - Safe file handling and cleanup

๐Ÿš€ Installation & Setup

Prerequisites

- Python 3.8 or higher
- FFmpeg (for video/audio processing)
- Google Gemini API Key

Installation Steps

  1. Clone the Repository
git clone https://github.com/PolnareffTurtle/ad-intelligence
cd ad-intelligence
  1. Create Virtual Environment
python -m venv .venv
source .venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install Dependencies
pip install -r requirements.txt
  1. Install FFmpeg

    • macOS: brew install ffmpeg
    • Ubuntu/Debian: sudo apt-get install ffmpeg
    • Windows: Download from ffmpeg.org
  2. Configure Environment Variables

# Create .env file
touch .env

# Add your Gemini API key (add this to the .env file)
echo "GEMINI_API_KEY=your_gemini_api_key_here" >> .env
  1. Run the Application
streamlit run calhacks.py
  1. Alternatives to Website
python3 main.py # this runs the image/video processing, shows run time
python3 audio.py # this runs the audio processing

The app will open automatically in your browser at http://localhost:8501

๐Ÿ“ฆ Dependencies

streamlit>=1.28.0
opencv-python>=4.8.0
numpy>=1.24.0
Pillow>=10.0.0
google-generativeai>=0.3.0
pydantic>=2.0.0
python-dotenv>=1.0.0

๐ŸŽฎ Usage Guide

Analyzing an Image Ad

  1. Click "๐Ÿ“ท Upload Image Ad" on the homepage
  2. Select one or more image files (PNG, JPG, JPEG)
  3. Preview your upload and click "๐Ÿ” Analyze Ad(s)"
  4. Review metrics in the analysis dashboard
  5. Download results as JSON for reporting

Analyzing a Video Ad

  1. Click "๐ŸŽฅ Upload Video Ad" on the homepage
  2. Select a video file (MP4, MOV, AVI)
  3. Preview your upload and click "๐Ÿ” Analyze Ad(s)"
  4. Wait for video and audio processing (may take 30-60 seconds)
  5. Review comprehensive metrics across visual and audio dimensions

Batch Analysis

  • Upload multiple images at once for comparative analysis
  • View timing metrics for each file processed
  • Access all results from the media library

Managing History

  • View all uploaded images via "๐Ÿ–ผ๏ธ All Images"
  • View all uploaded videos via "๐ŸŽฌ All Videos"
  • Clear specific media types or entire history via "๐Ÿ—‘๏ธ Clear History"

๐Ÿ”ฌ Methodology

Image Analysis Pipeline

  1. Preprocessing - Resize and normalize images for consistent analysis
  2. Edge Detection - Canny algorithm for negative space calculation
  3. Local Contrast - Kernel-based intensity variance measurement
  4. AI Vision - Gemini 2.5 Flash for semantic understanding
  5. Metric Normalization - Scale all values to [0, 1] for comparability

Video Analysis Pipeline

  1. Frame Extraction - Sample key frames (start, end, and midpoints)
  2. Motion Analysis - Laplacian variance for blur detection
  3. Scene Detection - Frame differencing for transition identification
  4. Audio Extraction - FFmpeg conversion to WAV format
  5. Audio Analysis - Peak detection, voice isolation, music classification
  6. Temporal Metrics - First 3-second hook and loudness progression

AI Integration

  • Gemini 2.5 Flash provides structured JSON responses with thinking budgets
  • Pydantic Models ensure type safety and schema validation
  • Fallback Handling for graceful degradation when AI is unavailable


๐Ÿ”ฎ Future Enhancements

  • Engagement Prediction Model - ML model trained on historical ad performance
  • Competitor Benchmarking - Compare your ads to industry standards
  • Platform-Specific Optimization - Instagram vs. YouTube vs. TikTok recommendations
  • A/B Test Suggestions - AI-generated variation recommendations
  • Real-time Feedback - Live metrics during ad creation
  • Team Collaboration - Shared workspaces and commenting
  • API Access - Programmatic analysis for CI/CD pipelines
  • Advanced Audio NLP - Sentiment and message clarity analysis

๐Ÿ‘ฅ Team

Calhacks 12.0 Team

  • Kshitij Tomar - Team Member #1
  • Yechan Park - Team Member #2
  • Theo Dela Cruz - Team Member #3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages