save code
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Running the Services
|
||||
|
||||
Each service runs independently and must be started separately:
|
||||
|
||||
```bash
|
||||
# Shirt-only try-on service (port 8888)
|
||||
python change2/service2.py
|
||||
|
||||
# Shirt + pants try-on service (port 8889)
|
||||
python change3/service3.py
|
||||
|
||||
# Gateway router (port 28888) — requires Flask
|
||||
python change_app.py
|
||||
```
|
||||
|
||||
ComfyUI must be running at `http://127.0.0.1:8188` before starting the services.
|
||||
|
||||
## Dependencies
|
||||
|
||||
```bash
|
||||
pip install fastapi uvicorn httpx pydantic flask requests
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
This is a three-tier AI virtual try-on system built around ComfyUI.
|
||||
|
||||
```
|
||||
Client
|
||||
└─► change_app.py (Flask, port 28888) ← Gateway router
|
||||
├─► change2/service2.py (FastAPI, port 8888) ← shirt-only
|
||||
└─► change3/service3.py (FastAPI, port 8889) ← shirt + pants
|
||||
└─► ComfyUI (port 8188)
|
||||
```
|
||||
|
||||
**Gateway** (`change_app.py`): Accepts `POST /change_cloth_base64` with `human_img`, `cloth_img`, and optional `kuzi_img` (pants). Routes to `service3` when `kuzi_img` is present, otherwise to `service2`. Both backends are called at `/do_change_cloth`.
|
||||
|
||||
**service2** (`change2/service2.py`): Handles shirt-only try-on. Exposes `POST /try-on` with `model_image` + `shirt_image`. Uses ComfyUI workflow `change2_1_ex.json`.
|
||||
|
||||
**service3** (`change3/service3.py`): Handles shirt + pants try-on. Exposes `POST /try-on` with `model_image` + `shirt_image` + `pants_image`. Uses ComfyUI workflow `change2_2_0308.json`.
|
||||
|
||||
### ComfyUI Workflow Integration
|
||||
|
||||
Both services dynamically modify a JSON workflow template before submission:
|
||||
|
||||
| Node ID | Purpose | service2 | service3 |
|
||||
|---------|---------|----------|----------|
|
||||
| `"11"` | Model/person image | ✓ | ✓ |
|
||||
| `"10"` | Shirt image | ✓ | ✓ |
|
||||
| `"4"` | Pants image | — | ✓ |
|
||||
| `"33"` | Output image | ✓ | ✓ |
|
||||
|
||||
The request flow within each service:
|
||||
1. Decode base64 images
|
||||
2. Upload images to ComfyUI (`/upload/image`) with UUID-prefixed filenames to avoid cache collisions
|
||||
3. Inject filenames into workflow node inputs
|
||||
4. Submit workflow to ComfyUI queue (`/prompt`)
|
||||
5. Poll `/history/{prompt_id}` until `status.completed` is true (max 300s timeout, 2s poll interval)
|
||||
6. Download result from `/view` and return as base64
|
||||
|
||||
### Frontend
|
||||
|
||||
Each service has its own test UI at `/` (served from `<service_dir>/static/index.html`). The `change2` UI accepts 2 images; `change3` accepts 3 images. Both POST directly to the service's `/try-on` endpoint.
|
||||
Reference in New Issue
Block a user