ai_qc/backend/visual_qc_apps/amazon_required_elements/app.py
nickviljoen 20259dcad0 Add Honda client, video QC, session refresh, Amazon check tuning
- Add Honda client with static_general and video_general profiles
- Add video QC capability using Gemini native video analysis (4 checks:
  visual_quality, brand_consistency, text_legibility, pacing_flow)
- Add video_general profile assigned to all 8 clients
- Extend session lifetime with MSAL silent token refresh (proactive
  every 45min + reactive on expiry), switch cache to localStorage
- Re-enable OCR layout measurements for Amazon checks
- Add scope boundary notes to all 6 Amazon checks to prevent cross-
  check penalization (locale errors isolated to logo_country only)
- Relax margins left-alignment tolerance from 1% to 4% to account
  for logo lockup internal padding
- Update brand guidelines DB with Amazon localization matrix and
  processed Dove PDF summary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 14:53:52 +02:00

84 lines
4.7 KiB
Python

import os
import sys
# Add parent directory to path to import shared modules
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from visual_qc_apps.flask_app_template import FlaskAppTemplate
class AmazonRequiredElementsApp(FlaskAppTemplate):
"""
Amazon ASD 2025 - Required Elements Check
Verifies all mandatory layout elements are present in the design.
"""
def __init__(self):
prompt = """You are performing a visual quality-control check on an Amazon marketing asset. Your task is to verify that all required layout elements are present in the design.
IMPORTANT — SCOPE BOUNDARY: This check evaluates ONLY whether the required layout elements are physically present in the design. Do NOT penalise for locale/country errors (wrong URL, wrong language) — those are evaluated by the separate amazon_logo_country check. If the logo element exists but shows the wrong country URL, score the element as PRESENT. Score based on element presence, not content correctness.
AMAZON REQUIRED ELEMENTS:
Amazon marketing layouts contain the following elements:
CRITICAL ELEMENTS (must be present — absence is a major issue):
1. HEADLINE - The main promotional text (e.g. "Four days of big deals", sale messaging). This should be the largest and most prominent text element in the layout. It is always left-aligned.
2. BOX - The Amazon branded box graphic that contains the Amazon logo (or URL logo for emerging locales). This is a distinctive cardboard box shape with tape/flaps. In some display formats, a Paper Bag may be used instead of the Box.
IMPORTANT ELEMENTS (should be present in most formats):
3. DATE - The sale dates/timing information (e.g. "8-11 July", "8-11 luglio"). Usually positioned below or near the headline.
4. LEGAL LINE - Small disclaimer/legal text, typically at the bottom of the layout (e.g. "Exclusively for Prime members", "Solo per i clienti Prime"). Usually displayed in smaller, semi-transparent text.
OPTIONAL ELEMENT (nice to have, but NOT required for all formats):
5. SUBHEAD - Secondary text providing additional context (e.g. discount percentage, "Save up to XX%", additional promotional messaging). This is separate from the date.
- IMPORTANT: Many formats — especially OOH (Out of Home), DOOH, and simplified layouts — do NOT include a separate subhead. This is perfectly acceptable. The date text or campaign branding can serve as the secondary text element.
- Do NOT penalise an asset for missing a subhead if the layout otherwise contains a headline, box, date, and legal line.
- Only flag a missing subhead as a minor note, never as a primary reason for failure.
EXCEPTIONS FOR SMALL FORMATS:
- For very small formats (typically below 60 pixels in height), the layout may be reduced to just: Headline and Box/logo only. This is acceptable.
- For banners where one side is smaller than 49 pixels, the Amazon logo (white) may appear without the box.
ADDITIONAL ELEMENTS (not required but note if present):
- CTA (Call-to-Action) button - Used in digital display formats only.
- ASINs (product images) - Used in certain layouts only.
- Campaign branding text (e.g. "Prime Day", "amazon prime day") - Often appears near the bottom.
STEPS TO EVALUATE:
1. Scan the entire layout and identify each element present
2. Determine if this is a standard format or a small format
3. For standard formats: verify the CRITICAL elements (Headline, Box) and IMPORTANT elements (Date, Legal Line) are present
4. Note whether a subhead is present, but do not treat its absence as a failure
5. For small formats: verify at minimum the Headline and Box/logo are present
DECISION CRITERIA:
- PASS: Headline AND Box are present, plus Date and Legal Line are present in standard formats
- FAIL: Headline is missing, OR Box/logo is missing in a standard format
- MINOR ISSUES (reduce score slightly but do not fail): Date missing, Legal Line missing, or Subhead missing
YOUR OUTPUT:
Format your response as JSON:
{
"element_check": "Pass" or "Fail",
"format_type": "standard" or "small" or "OOH/DOOH",
"elements_found": {
"headline": true or false,
"box_or_logo": true or false,
"subhead": true or false,
"date": true or false,
"legal_line": true or false
},
"missing_elements": ["list of missing elements, empty array if none"],
"missing_severity": "critical" or "minor" or "none",
"additional_elements_found": ["CTA", "ASINs", "campaign branding", etc.],
"explanation": "Detailed description of what was found and any concerns",
"recommendations": ["List specific recommendations if applicable, else an empty array"]
}"""
super().__init__(__name__, prompt)
# Run the app if executed directly
if __name__ == "__main__":
app_instance = AmazonRequiredElementsApp()
app_instance.run()