Skip to content

khammal/RealDeal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RealDeal

🎯 Overview

RealDeal is an AI-powered authentication platform that verifies the authenticity of physical products, digital media, and information through advanced computer vision and natural language processing.

  • πŸ›οΈ Physical Products - Authenticate luxury goods, sneakers, collectibles, electronics
  • πŸ€– AI-Generated Content - Detect deepfakes and synthetic media
  • πŸ“° News & Information - Fact-check claims and verify sources
  • πŸ‘€ People - Research backgrounds and detect red flags

πŸ› οΈ Tech Stack

  • Python
  • Flask
  • PyTorch
  • NumPy
  • Scikit-learn
  • OpenCV
  • Nuxt
  • Vue.js
  • TypeScript
  • TailwindCSS
  • Google Gemini
  • Groq (LLaMA 3.1)
  • Supabase
  • SerpAPI

✨ Key Features

1. Product Authentication System

  • Dynamic Criteria Generation - AI searches the web for brand-specific authentication markers
  • Guided Photo Capture - Step-by-step instructions for capturing specific angles
  • Multi-Criterion Analysis - Parallel scoring of stitching, logos, materials, hardware
  • Image Similarity Scoring - SIFT, color histograms, SSIM, edge detection
  • Trust-Scored References - Prioritizes official brand sites over resale platforms
  • Real-Time Price Verification - Validates market value using web search

2. Deepfake Detection

  • Custom ResNet50 Model - Trained on extensive Real/Fake dataset
  • Instant Pre-Check - Analyzes images before any other processing
  • Configurable Threshold - Adjustable confidence levels (default: 60%)
  • Multi-Model Support - Extensible architecture for additional models

3. Fact-Checking Engine

  • Claim Extraction - Automatically identifies factual statements
  • Web Search Verification - Cross-references with reliable sources
  • Source Credibility Rating - Evaluates trustworthiness of sources
  • Evidence-Based Verdicts - TRUE/FALSE/PARTIALLY TRUE with explanations

4. Person Research

  • Background Investigation - Searches for controversies, crimes, records
  • Fakeness Score (0-100) - Quantifies trustworthiness
  • Red Flag Detection - Highlights serious concerns
  • Source Citations - Verifies information reliability


🌐 Screenshots/Demo

1. Landing Page

Landing page

2. Item Detection

Item Detection

3. Authentication Results - Authentic βœ…

Authentic Results

Authentic Results Details

4. Authentication Results - Counterfeit ❌

Counterfeit Results

Counterfeit Results Details

5. Fact-Checking Engine

Fact Check Results Fact Check Results

6. Deepfake Detection

Deepfake Detection Deepfake Detection

7. Person Research

Person Research


πŸ—οΈ Architecture

System Overview

graph TB
    subgraph "Frontend (Nuxt 3 + Vue 3)"
        UI[User Interface]
        Camera[Camera System]
        Upload[File Upload]
    end
    
    subgraph "Backend (Flask API)"
        API[API Gateway]
        ItemDetect[Item Detection]
        DeepfakeCheck[Deepfake Detection]
        Criteria[Criteria Generation]
        Analysis[Counterfeit Analysis]
        FactCheck[Fact Checking]
        PersonResearch[Person Research]
    end
    
    subgraph "AI Services"
        Gemini[Google Gemini 2.5 Pro]
        GeminiFlash[Gemini Flash]
        PyTorch[PyTorch ResNet50]
        Groq[Groq LLaMA]
    end
    
    subgraph "External APIs"
        SerpAPI[SerpAPI / Google Lens]
        GoogleSearch[Google Search]
        Supabase[Supabase Storage]
    end
    
    UI --> Camera
    UI --> Upload
    Camera --> API
    Upload --> API
    
    API --> ItemDetect
    ItemDetect --> DeepfakeCheck
    DeepfakeCheck --> Criteria
    Criteria --> Analysis
    API --> FactCheck
    API --> PersonResearch
    
    ItemDetect --> Gemini
    DeepfakeCheck --> PyTorch
    Criteria --> Gemini
    Criteria --> GoogleSearch
    Analysis --> GeminiFlash
    FactCheck --> Gemini
    FactCheck --> GoogleSearch
    PersonResearch --> GeminiFlash
    PersonResearch --> GoogleSearch
    
    ItemDetect --> Groq
    ItemDetect --> SerpAPI
    API --> Supabase
    
    style UI fill:#00DC82
    style API fill:#3178C6
    style Gemini fill:#4285F4
    style PyTorch fill:#EE4C2C
Loading

Backend Architecture

graph LR
    subgraph "API Layer"
        Flask[Flask Server]
    end
    
    subgraph "Detection Modules"
        Item[item_detection.py]
        AIDetect[ai_detection/]
        Counterfeit[counterfeit.py]
        FactC[fact_check.py]
        Person[person.py]
    end
    
    subgraph "Support Modules"
        Criteria[criteria.py]
        ReverseSearch[generate_real_images/]
        Similarity[image_similarity_scores/]
        Prompts[prompts/]
        Parser[llm_parser.py]
    end
    
    subgraph "Data Layer"
        Cache[(SQLite Cache)]
        Uploads[(/uploads)]
    end
    
    Flask --> Item
    Flask --> AIDetect
    Flask --> Counterfeit
    Flask --> FactC
    Flask --> Person
    
    Item --> Criteria
    Item --> ReverseSearch
    Counterfeit --> Criteria
    Counterfeit --> Similarity
    
    Item --> Prompts
    Counterfeit --> Prompts
    FactC --> Prompts
    Person --> Prompts
    
    Item --> Parser
    Counterfeit --> Parser
    
    Criteria --> Cache
    Flask --> Uploads
Loading

πŸ”„ Workflows

Product Authentication Flow

sequenceDiagram
    participant U as User
    participant FE as Frontend
    participant API as Flask API
    participant DF as Deepfake Detector
    participant ID as Item Detection
    participant RS as Reverse Search
    participant CG as Criteria Generator
    participant CA as Counterfeit Analyzer
    participant SS as Similarity Scorer
    
    U->>FE: Upload/Capture Image
    FE->>API: POST /detect
    
    API->>DF: Check if AI-generated
    alt Is Deepfake (β‰₯60%)
        DF-->>API: Deepfake Detected
        API-->>FE: Return Deepfake Warning
        FE-->>U: Show AI Detection Alert
    else Not Deepfake
        DF-->>API: Authentic Image
        API->>ID: Analyze Image
        ID->>RS: Reverse Image Search
        RS-->>ID: Reference Images + Trust Scores
        ID->>ID: Extract Product Name
        ID-->>API: Product Detected + References
        API-->>FE: Detection Result + Product Info
        FE-->>U: Show Product Modal
        
        U->>FE: Confirm & Specify Brand (optional)
        FE->>API: POST /criteria/:id
        API->>CG: Generate Criteria
        CG->>CG: Search Web for Auth Markers
        CG-->>API: Criteria + Locations
        API-->>FE: Guided Photo Instructions
        FE-->>U: Show Step-by-Step Guide
        
        loop For Each Criterion
            U->>FE: Capture Angle Photo
            FE->>FE: Store Image
        end
        
        FE->>API: POST /analyze/:id (all images)
        API->>SS: Calculate Similarity Scores
        SS-->>API: Similarity Results
        
        par Parallel Analysis
            API->>CA: Analyze Criterion 1
            API->>CA: Analyze Criterion 2
            API->>CA: Analyze Criterion N
        end
        
        CA-->>API: Aggregated Results
        API->>API: Calculate Overall Score
        API-->>FE: Authentication Report
        FE-->>U: Show Results (Authentic/Counterfeit)
    end
Loading

Deepfake Detection Flow

flowchart TD
    Start([User Uploads Image]) --> Upload[Save Image to /uploads]
    Upload --> DeepfakeCheck{Run Deepfake<br/>Detection Model}
    
    DeepfakeCheck -->|Probability β‰₯ 0.6| Flagged[Flag as AI-Generated]
    DeepfakeCheck -->|Probability < 0.6| Continue[Continue to<br/>Item Detection]
    
    Flagged --> CalcConfidence[Calculate Confidence Level]
    CalcConfidence --> ShowWarning[Return Deepfake Warning]
    ShowWarning --> End1([End: Show Alert to User])
    
    Continue --> ItemDetect[Detect Item Type]
    ItemDetect --> TypeCheck{Item Type?}
    
    TypeCheck -->|Product| ProductFlow[Product Authentication Flow]
    TypeCheck -->|Person| PersonFlow[Person Research Flow]
    TypeCheck -->|Text| FactCheckFlow[Fact-Check Flow]
    TypeCheck -->|Other| GeminiAnalysis[General AI Analysis]
    
    ProductFlow --> End2([Continue Product Auth])
    PersonFlow --> End3([Research Person])
    FactCheckFlow --> End4([Verify Claims])
    GeminiAnalysis --> End5([Return Analysis])
    
    style Flagged fill:#ff6b6b
    style ShowWarning fill:#ff6b6b
    style Continue fill:#51cf66
    style DeepfakeCheck fill:#ffd43b
Loading

Fact-Checking Flow

flowchart LR
    A[Image with Text] --> B[Extract Claims via OCR + AI]
    B --> C{Contains<br/>Factual Claims?}
    
    C -->|No| D[Return: No Claims Found]
    C -->|Yes| E[For Each Claim]
    
    E --> F[Search Web for Evidence]
    F --> G[Evaluate Sources]
    G --> H[Cross-Reference Multiple Sources]
    
    H --> I{Verdict}
    I -->|Supported| J[TRUE]
    I -->|Contradicted| K[FALSE]
    I -->|Mixed| L[PARTIALLY TRUE]
    I -->|Insufficient| M[UNVERIFIABLE]
    
    J --> N[Compile Report]
    K --> N
    L --> N
    M --> N
    
    N --> O[Calculate Confidence Score]
    O --> P[Return Results]
    
    style J fill:#51cf66
    style K fill:#ff6b6b
    style L fill:#ffd43b
    style M fill:#868e96
Loading

Trust Scoring System

graph TD
    URL[URL/Domain] --> Extract[Extract Domain]
    Extract --> Known{Known Brand?}
    
    Known -->|Yes| Official[Official Brand Site]
    Known -->|No| Dynamic[Dynamic Scoring]
    
    Official --> Score10[Trust Score: 1.0]
    
    Dynamic --> HTTPS{HTTPS?}
    HTTPS -->|Yes| Base1[Base: 0.4]
    HTTPS -->|No| Base2[Base: 0.3]
    
    Base1 --> Indicators
    Base2 --> Indicators
    
    Indicators[Check Indicators] --> Official2{Has 'official'<br/>'authorized'<br/>'certified'?}
    Official2 -->|Yes| Plus1[+0.15]
    Official2 -->|No| Plus2[+0.0]
    
    Plus1 --> Platform
    Plus2 --> Platform
    
    Platform{E-commerce<br/>Platform?} -->|Yes| MinTrust[Min Trust: 0.5]
    Platform -->|No| RedFlags
    
    MinTrust --> RedFlags
    RedFlags{Red Flags?<br/>'replica'<br/>'fake'<br/>'cheap'} -->|Yes| Penalty[-0.3]
    RedFlags -->|No| Boost
    
    Penalty --> Final
    Boost[Frequency Boost] --> Final[Final Trust Score]
    
    Final --> Clamp[Clamp to 0.0-1.0]
    
    style Score10 fill:#51cf66
    style Official fill:#51cf66
    style Penalty fill:#ff6b6b
    style RedFlags fill:#ffd43b
Loading

πŸš€ Setup & Installation

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • API Keys (see below)

Required API Keys

Create a .env file in the backend/ directory:

# AI Services
GEMINI_API_KEY=your_gemini_api_key
GROQ_API_KEY=your_groq_api_key

# Search & Storage
SERPAPI_API_KEY=your_serpapi_key
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key

Backend Setup

# Navigate to backend
cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run Flask server
python main.py

Frontend Setup

# Navigate to frontend
cd frontend

# Install dependencies
npm install

# Run development server
npm run dev

πŸ’‘ Use Cases

E-Commerce & Resale

  • Verify luxury goods before purchase (Poshmark, eBay, Grailed)
  • Authenticate sneakers (StockX, GOAT validation)
  • Check collectibles (trading cards, limited editions)

Social Media & News

  • Detect AI-generated profile pictures
  • Fact-check viral claims and screenshots
  • Verify news sources

Personal Safety

  • Research people before meetings (dating, business)
  • Verify online identities
  • Check backgrounds for hiring

Brand Protection

  • Monitor counterfeit products
  • Protect intellectual property
  • Maintain brand reputation

πŸ“ Project Structure

RealDeal/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ ai_detection/              # Deepfake detection module
β”‚   β”‚   β”œβ”€β”€ model.py               # ResNet50 model architecture
β”‚   β”‚   β”œβ”€β”€ inference.py           # Inference wrapper
β”‚   β”‚   β”œβ”€β”€ deepfake_model.pth     # Trained model weights
β”‚   β”‚   └── Dataset/               # Training data (Real/Fake)
β”‚   β”œβ”€β”€ generate_real_images/      # Reverse image search
β”‚   β”‚   β”œβ”€β”€ image_searcher.py      # Google Lens integration
β”‚   β”‚   β”œβ”€β”€ trust_scorer.py        # Domain trust scoring
β”‚   β”‚   β”œβ”€β”€ brand_detector.py      # Brand identification
β”‚   β”‚   └── utils.py               # Helper functions
β”‚   β”œβ”€β”€ image_similarity_scores/   # Image comparison
β”‚   β”‚   β”œβ”€β”€ similarity_calculator.py  # Multi-metric scoring
β”‚   β”‚   β”œβ”€β”€ feature_extractors.py     # SIFT, color, edge
β”‚   β”‚   └── comparison_analyzer.py    # High-level API
β”‚   β”œβ”€β”€ prompts/                   # AI prompt templates
β”‚   β”‚   β”œβ”€β”€ criteria.py
β”‚   β”‚   β”œβ”€β”€ counterfeit.py
β”‚   β”‚   β”œβ”€β”€ fact_check.py
β”‚   β”‚   └── person.py
β”‚   β”œβ”€β”€ main.py                    # Flask API server
β”‚   β”œβ”€β”€ criteria.py                # Criteria generation
β”‚   β”œβ”€β”€ counterfeit.py             # Counterfeit analysis
β”‚   β”œβ”€β”€ fact_check.py              # Fact checking
β”‚   β”œβ”€β”€ person.py                  # Person research
β”‚   β”œβ”€β”€ item_detection.py          # Item classification
β”‚   β”œβ”€β”€ llm_parser.py              # JSON parsing
β”‚   β”œβ”€β”€ upload_image.py            # Supabase integration
β”‚   β”œβ”€β”€ requirements.txt           # Python dependencies
β”‚   └── criteria_cache.db          # SQLite cache
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ index.vue              # Landing page
β”‚   β”‚   └── detect.vue             # Detection interface
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ CameraView.vue
β”‚   β”‚   β”œβ”€β”€ CriteriaCapture.vue
β”‚   β”‚   β”œβ”€β”€ DetectionResults.vue
β”‚   β”‚   β”œβ”€β”€ AnalysisResults.vue
β”‚   β”‚   β”œβ”€β”€ DeepfakeResults.vue
β”‚   β”‚   β”œβ”€β”€ PersonInput.vue
β”‚   β”‚   β”œβ”€β”€ PersonResults.vue
β”‚   β”‚   └── FactCheckResults.vue
β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── images/
β”‚   β”œβ”€β”€ nuxt.config.ts             # Nuxt configuration
β”‚   β”œβ”€β”€ package.json               # Node dependencies
β”‚   └── tsconfig.json              # TypeScript config
β”‚
└── README.md                      # This file

πŸ”¬ How It Works

Product Authentication Algorithm

1. Image Upload β†’ Deepfake Pre-Check
   β”œβ”€ IF deepfake probability β‰₯ 60% β†’ STOP, show warning
   └─ ELSE β†’ Continue

2. Item Detection (Gemini Vision)
   β”œβ”€ Classify: product/person/text/other
   └─ Extract: product name, brand, description

3. Reverse Image Search (Google Lens)
   β”œβ”€ Find similar images
   β”œβ”€ Extract reference images from trusted sources
   β”œβ”€ Calculate trust scores (official brand = 1.0)
   └─ Detect brand from search results

4. Criteria Generation (Gemini + Web Search)
   β”œβ”€ Search web for authentication guides
   β”œβ”€ Extract key features: logo, stitching, materials
   β”œβ”€ Generate photo instructions
   └─ Cache with semantic similarity

5. Guided Photo Capture (Frontend)
   β”œβ”€ Show criterion 1 β†’ Capture
   β”œβ”€ Show criterion 2 β†’ Capture
   └─ ... β†’ Submit all images

6. Parallel Analysis (ThreadPoolExecutor)
   β”œβ”€ Criterion 1 β†’ Gemini Flash β†’ Score 1-5
   β”œβ”€ Criterion 2 β†’ Gemini Flash β†’ Score 1-5
   └─ Criterion N β†’ Gemini Flash β†’ Score 1-5

7. Image Similarity (OpenCV)
   β”œβ”€ SIFT feature matching (25%)
   β”œβ”€ Color histogram (35%)
   β”œβ”€ SSIM structural (20%)
   β”œβ”€ Edge detection (15%)
   └─ Shape analysis (5%)

8. Final Verdict
   β”œβ”€ Aggregate scores β†’ Overall confidence
   β”œβ”€ Calculate risk level
   β”œβ”€ Generate recommendations
   └─ Return report to user

Trust Scoring Formula

base_score = 0.3  # Unknown domains

# Factors:
+ 1.0   if official brand domain (hardcoded)
+ 0.1   if HTTPS
+ 0.15  if 'official', 'authorized', 'certified' in domain
+ 0.5   if e-commerce platform (Amazon, eBay, etc.)
- 0.3   if 'replica', 'fake', 'cheap' in domain/path
+ 0.15  if domain appears 3+ times in results
+ 0.08  if domain appears 2 times

final_score = clamp(base_score + adjustments, 0.0, 1.0)

πŸ§ͺ Testing

Backend Tests

cd backend

# Test reverse image search
python test_materials/test_reverse_search.py

# Test similarity scoring
python test_materials/example_similarity_usage.py

# Test item detection
python item_detection.py

# Test fact checking
python fact_check.py test_materials/fact_check.png

Model Testing

# Test deepfake detection
cd backend/ai_detection
python inference.py path/to/image.jpg deepfake_model.pth

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages