2.3 KiB
2.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a FastAPI-based virtual try-on service that integrates with ComfyUI for AI-powered clothing try-on. The service accepts base64-encoded images (model photo, shirt, pants) and returns a generated try-on result.
Running the Service
Start the server:
python service2.py
The server runs on http://0.0.0.0:47698 by default.
Dependencies
Required Python packages (install via pip):
- fastapi
- uvicorn
- httpx
- pydantic
Architecture
Request Flow
- Client sends POST to
/try-onwith base64 images (model_image, shirt_image, pants_image) - Server decodes images and uploads to ComfyUI at
http://127.0.0.1:8188 - Server modifies workflow JSON (change2_1_ex.json) with uploaded image filenames
- Workflow submitted to ComfyUI queue
- Server polls ComfyUI history endpoint until completion (max 300s timeout)
- Result image downloaded from ComfyUI and returned as base64
Key Components
service2.py: Main FastAPI application
/try-on: Main endpoint for virtual try-on/health: Health check endpoint/: Serves static frontend (index.html)
change2_1_ex.json: ComfyUI workflow configuration
- Node "11": Model image input (LoadImage)
- Node "10": Shirt image input (LoadImage)
- Node "33": Output image (SaveImage)
- Node "31": Text prompt for image editing
static/index.html: Frontend interface for testing
ComfyUI Integration
The service expects ComfyUI to be running at http://127.0.0.1:8188 with:
- FireRed-Image-Edit model loaded
- Qwen 2.5 VL CLIP model
- Required custom nodes for QwenEditConfigPreparer, QwenEditOutputExtractor
Workflow Modification
When processing requests, the code dynamically updates these workflow nodes:
workflow["11"]["inputs"]["image"]: Model photo filenameworkflow["10"]["inputs"]["image"]: Shirt photo filenameworkflow["31"]["inputs"]["value"]: Text prompt (currently hardcoded in Chinese)
Important Notes
- Images are uploaded with unique filenames (UUID prefix) to avoid caching issues
- The pants_image parameter is currently unused (commented out in code)
- Workflow uses 8 sampling steps with euler sampler and beta scheduler
- Output resolution is 768x1024 pixels
- CORS is enabled for all origins