← back to Wallco Ai

COMFYUI_SETUP.md

78 lines

# ComfyUI setup for wallco.ai

Wallco.ai's design generator can use ComfyUI as its diffusion backend
(`GEN_BACKEND=comfy`). The integration code (see `scripts/generate_designs.js`
function `genComfy`) is wired and will work as soon as ComfyUI is reachable.

## Where to install

Mac2 (32 GB RAM, M-series) can run SDXL at ~25-40s/image via MPS. The
recommended host is **Mac2** so the generator runs locally without round-trips
to Mac1 or the cloud.

## Install steps (one-time, ~15 min + model downloads)

```bash
# 1. Clone ComfyUI
cd ~/Projects
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI

# 2. Python venv + torch (MPS support for Apple Silicon)
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install torch torchvision  # MPS support automatic on Apple Silicon
pip install -r requirements.txt

# 3. Download SDXL base + refiner models (~12 GB total)
cd models/checkpoints
curl -L -O https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors
# (optional) curl -L -O https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors

# 4. Run it (default port 8188)
cd ~/Projects/ComfyUI
source venv/bin/activate
python main.py --listen 127.0.0.1 --port 8188
```

## Run as a persistent pm2 process

```bash
cd ~/Projects/ComfyUI
pm2 start "venv/bin/python main.py --listen 127.0.0.1 --port 8188" --name comfyui
pm2 save
```

## Wire into wallco.ai

Add to `~/Projects/wallco-ai/.env`:
```
GEN_BACKEND=comfy
COMFY_URL=http://127.0.0.1:8188
COMFY_MODEL=sd_xl_base_1.0.safetensors
COMFY_WIDTH=1024
COMFY_HEIGHT=1024
```

Then:
```bash
node scripts/generate_designs.js --n 10 --kind seamless_tile --category floral
```

## Seamless-tile notes

SDXL doesn't natively produce perfectly-seamless tiles. The integration appends
"seamless tile, repeating pattern, no edges" to the prompt + negatives the
seam/border/frame. This gets ≈80% of the way there.

For real-print-quality seamless output, swap `COMFY_MODEL` to a SDXL fine-tune
trained on tileable patterns (search HF for `sdxl seamless tile`), OR use the
"ImageBlur + offset" post-process (custom workflow JSON) to fix edge seams.

## Mural mode

Set `--kind mural --width 96 --height 108 --panels 4` to generate a 96×108"
mural split into 4 panels. The current code generates the full image then
splits into panels via Pillow post-process (TBD — open task).