ai_qc/backend/visual_qc_apps/new_visibility/app.py
nickviljoen 3fec052c12 Create frontend and backend folder structure for deployment
Organized the application into separate frontend and backend directories for cleaner deployment and better separation of concerns.

Frontend Directory (frontend/):
- index.html: Single-page web interface (renamed from web_ui.html)
- README.md: Frontend deployment guide
- Total size: ~113 KB (self-contained)
- Smart base path detection (works at / or /ai_qc/)
- No configuration changes required

Backend Directory (backend/):
- All Python files (api_server.py, llm_config.py, etc.)
- visual_qc_apps/: 33 QC check modules
- profiles/: 6 QC profile configurations
- brand_guidelines/: Reference asset storage
- config/: Environment configurations
- scripts/: Deployment automation
- uploads/, output/: Data directories
- requirements.txt, ai_qc.service, apache_config.conf
- Complete documentation

New Documentation:
- FOLDER_STRUCTURE.md: Comprehensive guide to new structure
- frontend/README.md: Frontend deployment instructions
- backend/BACKEND_README.md: Backend deployment guide

Deployment Mapping:
- frontend/ → /var/www/html/ai_qc/ (web root)
- backend/ → /opt/ai_qc/ (application directory)

Benefits:
- Clear separation of concerns
- Backend code not in web-accessible directory
- Independent frontend/backend updates
- Matches server's existing patterns (/opt/veo3, /opt/voice2text)
- Industry-standard architecture
- Easy to deploy and maintain

Original files preserved in root directory for reference.
Ready for production deployment following MIGRATION_GUIDE.md.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 11:55:53 +02:00

61 lines
3.2 KiB
Python
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 NewVisibilityApp(FlaskAppTemplate):
"""
New Element Visibility
"""
def __init__(self):
# Define the hardcoded prompt
prompt = """You are performing a visual quality-control check on a Point of Sale (POS) advertisement. Your task is to determine whether the "NEW" graphic element meets these criteria, based on the display size:
IMPORTANT: If there is no word containing "New" (in any case variation like "NEW", "New", "new") in the advertisement, then this QC check is not relevant to this file. In such cases, return a full score (Pass) for this app with appropriate JSON indicating no "NEW" element is present.
• For large media (Floor-Standing Display Units, posters, etc.): The "NEW" graphic must be clearly visible and legible from a minimum distance of 3 meters.
• For smaller media (wobblers, shelf talkers, etc.): The "NEW" graphic must be clearly visible and legible from a minimum distance of 1 meter.
STEPS TO EVALUATE:
1. First, carefully scan the entire advertisement for any text containing "New" (case-insensitive: "NEW", "New", "new", etc.).
2. If NO "New" text is found anywhere in the advertisement:
- This check is not applicable to this file
- Return "Pass" with "new_present": false
- No further evaluation needed
3. If "New" text IS found, proceed with the following steps:
4. Visibility and Legibility: Examine the advertisement's overall layout.
5. Check whether the "NEW" graphic is large enough and has sufficient contrast to be readable from the specified distance.
6. Consider if viewing the design at a reduced scale or slightly out of focus affects legibility. If you can clearly read the "NEW" text at the required distance, it passes this checkpoint.
7. Coverage Assessment: Estimate the area occupied by the "NEW" graphic as a percentage of the total ad space.
A "NEW" graphic occupying less than 5% of the ad might not be clear. Consider this a fail unless the positioning or contrast compensates.
8. Recommendations: If the "NEW" graphic fails any criteria, provide 12 concise recommendations for improving its visibility and legibility.
YOUR OUTPUT:
State whether the "NEW" graphic is present.
Visibility and Legibility Result:
- If NO "New" text found: "Pass" (check not applicable)
- If "New" text found: "Pass" or "Fail" based on visibility criteria
Recommendations:
If it fails, provide 12 concise recommendations for improvement.
If no "New" text found, state "Check not applicable - no NEW element present."
JSON Output:
Include a JSON code block with the following fields:
{
"new_present": false (if no "New" text found) or true (if "New" text found),
"new_visibility_legibility": "Pass" (always Pass if new_present is false, otherwise Pass or Fail),
"new_coverage_percentage": "0" (if no "New" text found) or "XX" (actual percentage if found)
}"""
# Initialize the Flask app with the prompt
super().__init__(__name__, prompt)
# Run the app if executed directly
if __name__ == "__main__":
app = NewVisibilityApp()
app.run(debug=True)