How bradcstevens/az-image-description-ai-matching works
Project Type and Purpose
• This is a command-line image-processing tool (an open-source utility) written in Python.
• It uses Azure OpenAI and Azure Computer Vision to analyze food images, match them against a menu list, then rename and store results with confidence scores.
File Structure Analysis
• Top-level:
• run.py – application entry point (CLI orchestrator)
• app/ – modular source code
• images/ – input JPEG images
• results/ – timestamped output folders with renamed images and JSON reports
• requirements.txt, .env.example – dependencies and environment variables
• app/config (Pydantic settings), app/core (service integrations & business logic), app/utils (file operations), app/tests (pytest unit tests)
Key Insights from README
• Modular design with clear separation of concerns
• Two Azure services (Vision AI and OpenAI) used in “dual-model” fashion
• CLI supports flags for input folder, output folder, description file, service toggles
• Results include both renamed images and a JSON report per run
Components
a. Main Components
• CLI Runner (run.py)
• Configuration Loader (app/config/settings.py)
• File Utils (app/utils/file_utils.py)
• Image Analyzer (app/core/image_analyzer.py)
• Azure Vision Service Wrapper (app/core/azure_vision.py)
• Azure OpenAI Service Wrapper (app/core/azure_openai.py)
• Description Loader (food-descriptions.txt parser)
• Results Store (timestamped folder + results.json)
• External Services: Azure Computer Vision API, Azure OpenAI API
b. Relationships & Interactions
1. CLI Runner reads CLI args → loads settings
2. CLI triggers Description Loader → builds in-memory list of menu items
3. CLI scans images directory → for each image:
– calls Image Analyzer
• Image Analyzer invokes Azure Vision wrapper → receives tags, OCR text
• Image Analyzer invokes Azure OpenAI wrapper → receives semantic description & confidence
• Combines results → computes final confidence score
– calls File Utils to rename/move image into results folder
4. After all images processed, CLI writes results.json via File Utils
c. Architectural Patterns & Principles
• Modular service wrappers (single responsibility for each Azure API)
• Dependency injection: Image Analyzer takes service instances as parameters for testability
• Configuration abstraction through Pydantic models
• Utility layer for file operations, isolating side-effects
• Timestamped output for idempotent runs
d. Technologies & Frameworks
• Python 3.8+
• Pydantic (settings model)
• Azure SDKs for Vision and OpenAI
• pytest for unit testing
• dotenv for environment variables