How deepratna-awale/autoexpress works
Project type and purpose
• AutoExpress is a full-stack Python web application (Flask) that provides a browser UI for uploading an image, generating 28 facial expressions by orchestrating calls to the Automatic1111 Stable Diffusion WebUI API (with the After Detailer extension), and compositing the results into an output grid.
File structure
Top-level directories & files:
• autoexpress/ ← the main Python package
– create_grid.py ← assembles the generated images into a grid
– views.py ← Flask route handlers
– modules/ ← core processing components
• a1111_client.py ← HTTP client for the SD WebUI API
• expression_generator.py ← logic to iterate expressions & build prompts
• image_parser.py ← face detection/cropping
• background_remover.py ← optional bg-removal pre-processing
• json_handler.py ← builds/parses JSON payloads
• utils.py ← shared utility functions
– resources/ ← static JSON definitions & sample images
– static/ ← JS/CSS assets (UI logic & styling)
– templates/index.html ← single-page UI layout
• run.sh / run.bat ← startup scripts
• Dockerfile ← containerization
• requirements.txt ← Python dependencies
README for additional insights
• Confirms Flask-based UI; reliance on A1111 WebUI API (http://127.0.0.1:7860) with Adetailer for inpainting.
• No database—images flow in memory.
• User drops image → UI auto-populates metadata → “Generate” triggers backend orchestration → final grid returned & displayed.
a. Main components
• User’s Browser (Front-end)
– HTML/CSS/JS assets: drag-and-drop, settings panel, Generate button, live logs/progress
• AutoExpress Web Server (Back-end)
– Flask Application (views.py)
– Processing Modules (image_parser, background_remover, expression_generator, a1111_client, create_grid)
– Resource Loader (loads JSON prompt templates & expressions lists)
• External AI Service
– A1111 Stable Diffusion WebUI API + After Detailer Extension
b. Relationships & data flow
1. Browser → (HTTP POST/AJAX) → Flask “/upload” endpoint (raw image + settings)
2. Flask calls image_parser → optional background_remover → expression_generator
3. expression_generator loops 28 expressions: for each, json_handler builds payload → a1111_client sends HTTP request to A1111 API
4. A1111 API returns inpainted image → a1111_client hands it back to create_grid
5. create_grid composes final grid image → Flask returns it to Browser
6. Browser displays grid, logs, allows download
c. Architectural patterns / design principles
• Modular separation of concerns: parsing, prompt generation, API client, grid assembly.
• Stateless request handling (no persistent storage).
• External service orchestration via REST.
• Single-page UI with asynchronous calls.
d. Key technologies/frameworks
• Python 3.x, Flask
• Automatic1111 WebUI REST API
• After Detailer Extension for inpainting
• Plain JS + AJAX for front-end interactivity
• Docker for containerization
Essential architectural details to capture
• Clear boundaries: UI vs. server vs. external AI
• Data flow steps (upload → parse → generate → assemble → display)
• Module responsibilities inside the Flask app
• No persistent storage—stateless, in-memory processing
• Docker container abstraction, if deploying via Docker