Default-deny access model with admin grant/revoke via new User Access tab. /api/clients filters by user grants; client-scoped endpoints enforce access server-side. Admin role and client grants persist in user_access.json with audit trail in usage logs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| brand_guidelines | ||
| config | ||
| output | ||
| profiles | ||
| scripts | ||
| uploads | ||
| visual_qc_apps | ||
| ai_qc.service | ||
| apache_config.conf | ||
| api_server.py | ||
| auth_middleware.py | ||
| BACKEND_README.md | ||
| brand_guidelines_db.py | ||
| CLAUDE.md | ||
| CLEANUP_SUMMARY.md | ||
| client_config.py | ||
| config.env | ||
| DEPLOYMENT_RESTRUCTURE.md | ||
| DEV_PROD_SETUP.md | ||
| generate_usage_report.py | ||
| headless_curl_examples.sh | ||
| headless_example.py | ||
| jwt_validator.py | ||
| llm_config.py | ||
| localization_processor.py | ||
| media_plan_processor.py | ||
| migrate_output_files.py | ||
| MIGRATION_CHECKLIST.md | ||
| MIGRATION_GUIDE.md | ||
| MIGRATION_SUMMARY.md | ||
| msal_pkce_flow.md | ||
| NEW_FEATURES_QUICKSTART.md | ||
| ocr_measurement.py | ||
| pdf_processor.py | ||
| PRICING_GUIDE.md | ||
| profile_config.py | ||
| PROFILE_MANAGEMENT.md | ||
| README.md | ||
| requirements.txt | ||
| run_api_server.py | ||
| TOKEN_TRACKING_ENHANCEMENT.md | ||
| USAGE_REPORTS.md | ||
| usage_tracker.py | ||
| user_access.py | ||
| validate_pricing.py | ||
Visual AI QC - AI-Powered Quality Control Platform
AI-driven visual quality control system for marketing materials, advertisements, and design assets
Overview
Visual AI QC is an intelligent quality control platform that uses advanced AI (OpenAI GPT-4o and Google Gemini 2.5 Pro) to automatically analyze visual and video content against brand guidelines, technical specifications, and design best practices. The system provides comprehensive feedback, scoring, and recommendations for improving assets across 75 specialized QC checks, 14 profiles, and 8 clients.
Key Features
- AI-Powered Analysis: Leverages both OpenAI GPT-4o and Google Gemini 2.5 Pro for comprehensive visual analysis
- Video QC: Native video analysis using Gemini's video understanding (mp4, mov, avi, webm)
- OCR Layout Measurement: Tesseract OCR provides pixel-level measurements for margin, alignment, and spacing checks
- Multi-Client Platform: 8 client workspaces (Diageo, Unilever, L'Oreal, Amazon, Boots, Dow Jones, Honda, General)
- 14 QC Profiles: Brand-specific and general-purpose profiles with weighted scoring
- Real-Time Progress Tracking: Live analysis progress with batch-based parallel processing
- PDF Brand Guidelines: Upload multi-page PDF guidelines with automatic LLM summarization
- Media Plan Integration: Upload Excel media plans for automatic asset spec validation
- Enterprise Authentication: Microsoft Azure AD with MSAL/PKCE and silent token refresh
- Admin Panel: Platform-wide usage analytics, user tracking, and cost estimation
- Client-Scoped Reporting: Per-client usage dashboards with date range filtering
- Profile Versioning: Automatic version control when profiles are edited
System Architecture
Visual AI QC Platform
+-- Authentication Layer (MSAL/Azure AD with silent refresh)
| +-- JWT Token Validator (jwt_validator.py)
| +-- Auth Middleware (auth_middleware.py)
| +-- httpOnly Cookie Sessions
+-- Web Interface (web_ui.html)
+-- API Server (api_server.py) - Parallel batch processing
+-- LLM Engine (llm_config.py)
| +-- OpenAI GPT-4o (image analysis)
| +-- Gemini 2.5 Pro (image + video analysis)
+-- OCR Engine (ocr_measurement.py) - Tesseract pixel measurements
+-- QC Check Modules (visual_qc_apps/) - 75 checks
+-- Profile System (profiles/) - 14 profiles
+-- Client Config (client_config.py) - 8 clients
+-- Brand Guidelines DB (brand_guidelines/)
+-- Media Plan Processor (media_plan_processor.py)
+-- PDF Processor (pdf_processor.py)
+-- Usage Tracker (usage_tracker.py)
+-- Output Reports (output/)
Quick Start
Prerequisites
- Python 3.8+
- OpenAI API Key
- Google AI API Key
- Microsoft Azure AD account (for authentication)
- Tesseract OCR (optional, for pixel-level measurements):
brew install tesseract(macOS) orsudo apt install tesseract-ocr(Ubuntu)
Installation
-
Clone and Setup:
cd ai_qc/backend python -m venv venv source venv/bin/activate pip install -r requirements.txt -
Configure Development Environment:
cp config/.env.template config/development.env # Edit config/development.env with your API keys and Azure AD config -
Start Development Server:
./scripts/run-local.sh # Access at http://localhost:7183
Production Deployment
ssh user@server
cd /opt/ai_qc
git pull origin main
sudo chown -R www-data:www-data uploads output media_plans brand_guidelines backend/usage_logs
sudo systemctl restart ai_qc.service
Clients
| Client | Profiles | Description |
|---|---|---|
| Diageo | diageo_key_visual, diageo_packaging, static_general, video_general | Spirits brand visual and packaging QC |
| Unilever | unilever_key_visual, unilever_packaging, static_general, video_general | FMCG key visual and packaging QC with zero-score logic |
| L'Oreal | loreal_static, static_general, video_general | Beauty brand static QC with strict grading (any check <6 = Fail) |
| Amazon | amazon_static, static_general, video_general | ASD 2025 design compliance with OCR measurements |
| Boots | boots_static, static_general, video_general | Retail promotional artwork compliance |
| Dow Jones | dow_jones_static, marketwatch_static, wsj_static, static_general, video_general | Corporate + sub-brand QC for DJ, MarketWatch, WSJ |
| Honda | static_general, video_general | Automotive marketing QC |
| General / Other | static_general, video_general, inclusive_accessibility | General-purpose and accessibility checks |
QC Profiles
Static Profiles
| Profile | Checks | Scale | Description |
|---|---|---|---|
| General Check | 10 | 100-point | General-purpose QC with even weighting |
| Static General | 10 | 100-point | Baseline digital static asset QC used by all clients |
| Unilever Key Visual | 15 | 120-point | Unilever brand guidelines with bonus check zero-scoring |
| Unilever Packaging | 17 | 100-point | Unilever packaging design standards |
| Diageo Key Visual | 11 | 100-point | Diageo brand guidelines for key visuals |
| Diageo Packaging | 13 | 100-point | Diageo packaging design standards |
| L'Oreal Static | 4 | 100-point | Focused L'Oreal QC (any check <6 = overall Fail) |
| Amazon Static | 6 | 100-point | ASD 2025 compliance with OCR support |
| Boots Static | 5 | 100-point | Retail compliance (any check <6 = overall Fail) |
| Dow Jones Static | 5 | 100-point | Corporate brand QC |
| MarketWatch Static | 6 | 100-point | MarketWatch sub-brand QC |
| WSJ Static | 6 | 100-point | Wall Street Journal sub-brand QC |
| Inclusive Accessibility | 2 | 100-point | Accessibility and inclusive design |
Video Profile
| Profile | Checks | Scale | Description |
|---|---|---|---|
| Video General | 4 | 100-point | Video QC using Gemini native video analysis |
Video checks: video_visual_quality, video_brand_consistency, video_text_legibility, video_pacing_flow
Video analysis uses Gemini's File Upload API to process the full video (motion, transitions, temporal flow) rather than just extracting frames. Gemini is automatically selected for video files regardless of profile LLM setting.
Amazon QC Checks (with OCR)
The 6 Amazon checks have clearly defined scope boundaries to prevent cross-check penalization:
| Check | Scope | OCR Enhanced |
|---|---|---|
| amazon_required_elements | Element presence only (not content correctness) | No |
| amazon_logo_country | Locale/country URL and logo correctness | No |
| amazon_typography | Font, size ratios, leading, tracking, spacing, ligatures | Yes |
| amazon_headline_layout | Alignment, prominence, positioning, line breaks | Yes |
| amazon_margins | Margin distances, left-alignment consistency | Yes |
| amazon_element_placement | Box positioning, cropping rules, tape visibility | No |
OCR provides Tesseract pixel-level measurements to the 3 layout-sensitive checks. Checks gracefully fall back to visual estimation when OCR is unavailable.
Scoring System
Individual Check Scores
- Each check scores 1-10
- 8-10: Pass (Green)
- 5-7: Adequate (Yellow)
- 1-4: Fail (Red)
Overall Score
- Weighted average scaled to 100 points
- Weights defined per-profile
- Special rules: L'Oreal and Boots profiles fail overall if any individual check scores below 6
Grades
- A (85-100): Excellent
- B (70-84): Good
- C (50-69): Adequate
- D (35-49): Poor
- F (0-34): Fail
Supported File Types
Input
- Images: PNG, JPG, JPEG, BMP, WebP, GIF, TIFF
- PDFs: First page extracted as image for analysis
- Video: MP4, MOV, AVI, WebM, MKV, WMV, FLV (Gemini only)
Brand Guidelines
- PDF: Multi-page with automatic text extraction and LLM summarization
- Images: PNG, JPG, GIF, JPEG
- Excel: XLSX/XLS for media plans and localization matrices
Output
- HTML Reports: Visual reports with expandable sections and scoring
- JSON Data: Raw analysis data for programmatic processing
Authentication
Azure AD with MSAL
- PKCE security flow for single-page applications
- httpOnly cookie session management
- Silent token refresh every 45 minutes (sessions last full workday)
- Proactive + reactive refresh to prevent session expiry
- localStorage-based MSAL cache for cross-tab persistence
Admin Panel
- Accessible to users in the
ADMIN_USERSlist (backend/client_config.py) - Platform-wide usage stats: total users, analyses, estimated cost
- Per-user breakdown: analyses, checks, clients used, last active
API Endpoints
Authentication
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/login |
Validate MSAL token, create session |
| POST | /auth/logout |
Clear session |
| GET | /auth/status |
Check auth status, log user visit |
Analysis
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/start_analysis |
Start async analysis (auth required) |
| GET | /api/progress/{session_id} |
Get real-time progress |
| POST | /api/process_file |
Direct file processing (auth required) |
Profiles & Guidelines
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/profiles |
List profiles for client |
| POST | /api/profiles |
Create new profile (auto-versioned) |
| PUT | /api/profiles/{id} |
Edit profile (creates new version) |
| POST | /api/brand_guidelines |
Upload brand guideline |
| GET | /api/brand_guidelines/{id}/status |
Check PDF processing status |
Admin & Reporting
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/admin/check |
Check if user is admin |
| GET | /api/admin/users |
Get all platform users (admin only) |
| GET | /api/client_usage_stats |
Client-scoped usage report |
Media Plans
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/media_plan |
Upload Excel media plan |
| GET | /api/media_plan?client={id} |
Get client's media plan |
| DELETE | /api/media_plan/{client_id} |
Remove media plan |
Configuration
Environment Variables
OPENAI_API_KEY=your_openai_key
GOOGLE_API_KEY=your_google_key
AZURE_TENANT_ID=your_tenant_id
AZURE_CLIENT_ID=your_client_id
SECRET_KEY=your_flask_secret
FLASK_PORT=7183
DEBUG_MODE=false
ENVIRONMENT=development # or production
Adding New QC Checks
- Create directory:
visual_qc_apps/{check_name}/ - Create
app.pyusingflask_app_template.pyas base - Add check to relevant profile JSON files
- Restart server
Adding New Clients
Add entry to CLIENT_PROFILES in client_config.py:
'client_id': {
'name': 'Client Name',
'profiles': ['static_general', 'video_general'],
'display_name': 'Client Name',
'description': 'Description of client QC needs'
}
Documentation
- CLAUDE.md - Full development guide and system documentation
- CLAUDE_AMAZON.md - Amazon check details and prompt tuning history
- CLAUDE_BOOTS.md - Boots check details
- CLAUDE_DOW_JONES.md - Dow Jones / MarketWatch / WSJ check details
- CLAUDE_LOREAL.md - L'Oreal check details and prompt tuning history
- DEV_PROD_SETUP.md - Development and production environment guide
- backend/USAGE_REPORTS.md - Usage reporting CLI tool guide
- backend/PROFILE_MANAGEMENT.md - Profile versioning and visibility guide
License
This project is proprietary software. All rights reserved.
Visual AI QC Platform - Ensuring quality through intelligent automation