OCR measurements were causing the LLM to over-rely on bounding box numbers and fail correct assets on minor measurement inaccuracies. Changes: - All prompts now say "supplementary data" not "authoritative/primary source" - LLM instructed to prioritise visual assessment, use OCR to confirm/question - Alignment tolerance widened from 1.5% to 3% of width - OCR context footer softened with accuracy caveat (~5-10px margin of error) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59 lines
No EOL
2.7 KiB
Python
Executable file
59 lines
No EOL
2.7 KiB
Python
Executable file
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 ElementAlignmentApp(FlaskAppTemplate):
|
|
"""
|
|
Element Alignment Check
|
|
"""
|
|
|
|
def __init__(self):
|
|
# Define the hardcoded prompt
|
|
prompt = """You are performing a visual quality-control check on an advertisement to verify the alignment of its elements. Your task is to determine whether all design elements are properly aligned according to professional design standards.
|
|
|
|
MEASUREMENT DATA:
|
|
If OCR LAYOUT MEASUREMENTS are provided at the end of this prompt, use them as supplementary data to support your visual alignment assessment. OCR bounding boxes can have small inaccuracies, so use them to confirm or question what you see visually, but prioritise the overall visual impression of alignment quality.
|
|
|
|
ALIGNMENT CRITERIA:
|
|
1. Elements should be aligned horizontally and vertically where appropriate
|
|
2. Text blocks should have consistent alignment (left, right, center, or justified)
|
|
3. Related elements should share alignment points
|
|
4. Elements should align with a visible or implied grid structure
|
|
5. Centered elements should be precisely centered
|
|
6. Key alignment points include:
|
|
- Edges (top, bottom, left, right)
|
|
- Centers (horizontal and vertical)
|
|
- Baselines (for text)
|
|
|
|
STEPS TO EVALUATE:
|
|
1. Identify key elements in the design (logos, text blocks, images, buttons, etc.)
|
|
2. Check horizontal alignment of elements (left, center, right)
|
|
3. Check vertical alignment of elements (top, middle, bottom)
|
|
4. Look for any elements that appear misaligned or "off by a few pixels"
|
|
5. Check if text has consistent alignment (especially within the same block)
|
|
6. Check if centered elements are precisely centered
|
|
7. Look for any visible guides or grid systems and check if elements align with them
|
|
|
|
YOUR OUTPUT:
|
|
• State whether all elements appear properly aligned
|
|
• If any misalignment is detected, identify the specific elements and alignment issues
|
|
• Provide recommendations for correcting any alignment issues
|
|
• Include a JSON code block with these fields:
|
|
{
|
|
"all_elements_properly_aligned": true or false,
|
|
"alignment_check": "Pass" or "Fail",
|
|
"misaligned_elements": ["List specific misaligned elements, if any, else an empty array"],
|
|
"recommendations": ["List specific alignment recommendations if applicable, else an empty array"]
|
|
}"""
|
|
|
|
# Initialize the Flask app with the prompt
|
|
super().__init__(__name__, prompt)
|
|
|
|
# Run the app if executed directly
|
|
if __name__ == "__main__":
|
|
app = ElementAlignmentApp()
|
|
app.run(debug=True) |