No description
Find a file
2025-10-01 14:32:55 -05:00
example_code initial commit 2025-10-01 14:32:55 -05:00
.gitignore initial commit 2025-10-01 14:32:55 -05:00
advanced_splitter.py initial commit 2025-10-01 14:32:55 -05:00
check_system_resources.py initial commit 2025-10-01 14:32:55 -05:00
cli.py initial commit 2025-10-01 14:32:55 -05:00
cost_calculator.py initial commit 2025-10-01 14:32:55 -05:00
COST_TRACKING_README.md initial commit 2025-10-01 14:32:55 -05:00
fix_stalled_processing.py initial commit 2025-10-01 14:32:55 -05:00
gemini_detector.py initial commit 2025-10-01 14:32:55 -05:00
hybrid_detector.py initial commit 2025-10-01 14:32:55 -05:00
image_detector.py initial commit 2025-10-01 14:32:55 -05:00
improved_splitting.py initial commit 2025-10-01 14:32:55 -05:00
logging_config.py initial commit 2025-10-01 14:32:55 -05:00
master_adapt_detector_diagram.md initial commit 2025-10-01 14:32:55 -05:00
MEMORY_FIX_SUMMARY.md initial commit 2025-10-01 14:32:55 -05:00
memory_manager.py initial commit 2025-10-01 14:32:55 -05:00
ONE_AT_A_TIME_COST_TRACKING.md initial commit 2025-10-01 14:32:55 -05:00
OPENAI_API_COST_TRACKING_VERIFICATION.md initial commit 2025-10-01 14:32:55 -05:00
openai_detector.py initial commit 2025-10-01 14:32:55 -05:00
optimize_split_parameters.py initial commit 2025-10-01 14:32:55 -05:00
panel_splitter.py initial commit 2025-10-01 14:32:55 -05:00
process_detection.py initial commit 2025-10-01 14:32:55 -05:00
README.md initial commit 2025-10-01 14:32:55 -05:00
requirements.txt initial commit 2025-10-01 14:32:55 -05:00
simple_splitter.py initial commit 2025-10-01 14:32:55 -05:00
SPLITTING_TEST_RESULTS.md initial commit 2025-10-01 14:32:55 -05:00
test_14_panel_split.py initial commit 2025-10-01 14:32:55 -05:00
test_6786505_cli.py initial commit 2025-10-01 14:32:55 -05:00
test_cost_calculator.py initial commit 2025-10-01 14:32:55 -05:00
test_cost_tracking_integration.py initial commit 2025-10-01 14:32:55 -05:00
test_horizontal_splitting.py initial commit 2025-10-01 14:32:55 -05:00
test_hybrid.py initial commit 2025-10-01 14:32:55 -05:00
test_memory_fix.py initial commit 2025-10-01 14:32:55 -05:00
test_one_at_a_time_cost_tracking.py initial commit 2025-10-01 14:32:55 -05:00
test_optimized_canny.py initial commit 2025-10-01 14:32:55 -05:00
test_panel_accuracy.py initial commit 2025-10-01 14:32:55 -05:00
test_parallel_implementation.py initial commit 2025-10-01 14:32:55 -05:00
test_simple_split.py initial commit 2025-10-01 14:32:55 -05:00
test_split_mode.py initial commit 2025-10-01 14:32:55 -05:00
tune_14_panel_split.py initial commit 2025-10-01 14:32:55 -05:00
vector_detector.py initial commit 2025-10-01 14:32:55 -05:00

Master Image Detection Application

This application uses Google Gemini 2.5 Pro API to detect which master images appear in layout images.

Features

  • Filename-based IDs: Master images are identified by their filenames (without .jpg extension)
  • Comprehensive Detection: Finds exact matches, cropped versions, scaled/rotated images
  • Detailed Results: JSON output with layout filenames and detected master filenames
  • Optimized Processing: Sequential processing with master images uploaded only once
  • Progress Tracking: Real-time progress updates and periodic saves during batch processing
  • Error Handling: Automatic retries and graceful error recovery

Setup

  1. Install Dependencies:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  2. Configure API Key:

    • API key is already set in .env file
    • Ensure .env file exists with your Gemini API key

Usage

Activate the virtual environment first:

source venv/bin/activate

Command Line Options

# Test with 1 layout
python image_detector.py --test

# Process first 10 layouts
python image_detector.py --limit 10

# Process all layouts
python image_detector.py --all

# Custom output filename
python image_detector.py --limit 50 --output my_batch_results

# Process all layouts (sequential but optimized)
python image_detector.py --all

# Custom paths
python image_detector.py --all --master-path /path/to/masters --layout-path /path/to/layouts

Help

python image_detector.py --help

Common Commands

# Quick test
python image_detector.py --test

# Small batch
python image_detector.py --limit 10

# Full processing (all 306 layouts) - optimized sequential
python image_detector.py --all

Output Format

Results are saved as JSON with this structure:

{
  "metadata": {
    "total_layouts_processed": 1,
    "total_master_images": 41,
    "master_images_available": ["1011A_1011_05", "1011A_1011_06", ...]
  },
  "results": {
    "6814786": {
      "layout_filename": "6814786.jpg",
      "detected_master_ids": ["1011A_1011_05"],
      "detected_master_filenames": ["1011A_1011_05.jpg"],
      "analysis": "Detailed analysis of what was found..."
    }
  }
}

Key Output Fields

  • layout_filename: The layout image filename
  • detected_master_ids: Master image IDs (filenames without .jpg)
  • detected_master_filenames: Full master image filenames with .jpg extension
  • analysis: Gemini's detailed explanation of the detection

Directory Structure

├── master_images/     # 41 master images to detect
├── layouts/          # 299+ layout images to analyze
├── results/          # JSON output files
├── venv/            # Python virtual environment
├── image_detector.py # Main application
├── test_simple.py   # API connection tester
├── requirements.txt # Dependencies
└── .env            # API configuration

Example Results

Layout 6814786.jpg contains master image 1011A_1011_05.jpg (cropped version).