This project provides a web-based AI agent that helps you optimize photo composition to get more aesthetically pleasing photos in just one minute.
You can upload a photo and describe how you want the composition improved in natural language. The system then plans the camera adjustment, generates several candidates, and selects the best one with feedback. You can inspect the results, interactively control the process, and download the final result from a web UI.
The system uses a pipeline of four specialized agents —
- Ice(冉冰): your assistant to chat with you and understand your concerns about how you'd like to change the photo;
- Moon(月魁): the composition planner;
- Mark(马克): the expert photographer who will efficiently help you adjust the photo with several candidates; and
- Mana(玛娜): the strict aesthetic judge — she will score the results provided by Mark based on the composition quality, intent match, and image content consistency, and force re-generation or re-planning if necessary.
After the system outputs the results, you can download the adjusted photo, or alternatively, iterate by pressing buttons to trigger re-generation, re-planning or give new instructions to Ice.
The Character names and persona design are borrowed from my favourite cartoon LingCage (灵笼).
The workflow is orchestrated with LangGraph over a shared-state blackboard; all model inference runs on the Alibaba DashScope cloud API with free quota (Qwen-VL + Qwen-Image-Edit), so no local GPU is required.
┌─────────────────────────────────────────────┐
React SPA ◄────►│ FastAPI (REST + SSE stream) │
(chat, panels, │ │ │
gallery, dl) │ ▼ │
│ LangGraph orchestrator (shared state) │
│ 1 Intention ─► 2 Planning ⇄ Inspection │
│ ▲ │ │
│ │(clarify) ▼ │
│ │ 3 Execution (4 candidates) │
│ │ │ │
│ └──── 4 Assessment ─► best / retry │
└───────────────┬──────────────┬──────────────┘
▼ ▼
Qwen-VL (DashScope) Qwen-Image-Edit (DashScope)
- One DashScope API key serves both Qwen-VL (stages 1/2/4) and Qwen-Image-Edit (stage 3).
- Agent thoughts, progress, candidates, and scores stream to the browser over SSE so every module's process is visible.
- Python 3.11 (conda environment is recommended)
- Node.js 18+ (for the frontend)
- You need to provide an Alibaba DashScope cloud API Key to run the demo. Please refer to DashScope documentation.
First, create a virtual conda environment:
conda create -n ai_composer python=3.11
pip install -r requirements.txt
conda activate ai_composer
Running this demo requires an Alibaba Dashscope API key, see Prerequisites.
# run demo using real AI models
cd backend
$env:DASHSCOPE_API_KEY=<YOUR_KEY>
uvicorn ai_composer.main:app --port 8000Note that the API key <YOUR_KEY> should look like "sk-ws-xxxxxx". Don't forget the "".
(Optional) Notice: If you want to test without running real AI models that require an API key, you can optionally use the mock-up mode with static responses by starting the backend with
# mock-up test mode without using real AI models
$env:AI_COMPOSER_DEMO="1"
uvicorn ai_composer.main:app --port 8000cd frontend
npm install # first time only
npm run devGo to http://localhost:5173, then: upload a photo → chat with Ice to confirm the goal → click Optimize composition → watch Moon → Mark → Mana run in the vertical pipeline → download the re-taken photo.
Each run will take in total about 1 minute to generate the final result.
The frontend calls the backend at
http://localhost:8000(seefrontend/src/api.js). If you change the backend port, updateBASEthere.
This project is released under the MIT License — see the LICENSE file for details.

