Commit Graph
14 Commits
Author SHA1 Message Date
Claude 3f4a6b754c Make model prefetching automatic in install/run scripts
install-local-gpu.sh and bring-up-local-gpu.sh now call
prefetch-models.sh --sdxl (host-side download, all models including
SDXL/inpaint, ~13GB) automatically rather than treating it as a manual
DNS-troubleshooting step. install-local-gpu.sh drops back to the
invoking user via sudo -u "$SUDO_USER" -H before running it, since
that script itself runs as root and would otherwise leave downloaded
files root-owned. Both call sites are non-fatal: a prefetch failure
logs a warning and the container still starts, falling back to its
own in-container download attempt.

Updated README to match.
2026-06-18 17:47:18 +00:00
Claude 3a977c7438 Add prefetch-models.sh to download AI models on host when container DNS is blocked
Lets SAM, U2Net, BEN2, and BiRefNet-HR (optionally SDXL via --sdxl) be
downloaded outside Docker into ./data/, which is already bind-mounted
into the GPU container — so a blocked container network no longer blocks
first-run setup. Reuses the existing dual-mode download_sam_model.py and
download_u2net_model.py as-is. For the HuggingFace Hub models, sets
HF_HOME (rather than --cache-dir) so the host-side cache layout matches
the container's default ~/.cache/huggingface resolution exactly, avoiding
a path-nesting mismatch between the two.

Wired into install-local-gpu.sh's completion banner and
bring-up-local-gpu.sh's header, and referenced from the relevant README
troubleshooting sections and the hf_cache bind-mount comment in
docker-compose.gpu.yml.
2026-06-18 16:13:11 +00:00
Claude 38e80f8fb8 Add BEN2 and BiRefNet-HR as selectable Remove Background models
BEN2 becomes the new default local backend (clean cutouts, strong on
hair/fur edges), with BiRefNet-HR available as a high-res/print
alternate and U2Net kept as the lightweight fallback. Both are
MIT-licensed and download weights from HuggingFace on first use
(cached via the existing hf_cache bind mount), unlike U2Net/SAM which
need an explicit download script.

- config: new BG_REMOVAL_MODEL setting (default "ben2")
- tools.py: remove-background-base64 now tries local backends in
  order (request.model override > BG_REMOVAL_MODEL > ben2/u2net),
  falling back to rembg's birefnet-general session as a last resort
- requirements.gpu.txt / Dockerfile.gpu: add ben2 + transformers deps
  needed for the new backends, with a build-time smoke test for ben2
- frontend: model dropdown in the Remove Background dialog, threaded
  through api.js to the new request field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ro4PwQKvSc3CH19LSN21Ht
2026-06-18 14:20:24 +00:00
Claude a4a9dbc33a Auto-download U2Net model on startup; remove dead PyTorch U2Net module
U2Net only ever downloaded lazily on the first Remove Background click,
unlike SAM which retries on every container start. If that one attempt
failed (DNS/firewall) the model was never fetched again, surfacing as
"No background removal method available. Install u2net or rembg."

Mirrors the existing SAM auto-download/AUTO_DOWNLOAD_SAM pattern for
U2Net, and documents manual host-side recovery in the README.

Also deletes backend/app/services/u2net_model.py (hand-written
U2NET/U2NETP PyTorch classes) — unused since tools.py switched to
cv2.dnn.readNetFromONNX for background removal.
2026-06-18 13:10:07 +00:00
Claude ea77d95ab0 Replace start-gpu.sh with install-local-gpu.sh + bring-up-local-gpu.sh
install-local-gpu.sh (run once):
- Installs nvidia-container-toolkit (Ubuntu/Debian/RHEL auto-detected)
- Installs docker-dns-fix.service systemd unit: permanent iptables DNS
  fix that runs after docker.service on every boot, without touching ufw
- Restarts Docker and applies the rule immediately
- Verifies GPU is accessible inside Docker

bring-up-local-gpu.sh (run each time):
- Thin wrapper: docker compose -f docker-compose.gpu.yml up -d --build
- Accepts pass-through args (down, logs -f, --no-build, etc.)
- BUILDID=$(date +%s) ./bring-up-local-gpu.sh for pip cache bust

README Quick Start, Updates, and Troubleshooting updated accordingly.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 01:04:26 +00:00
Claude 7cfbb6034f Add start-gpu.sh: auto-applies iptables DNS fix before container start
The iptables DOCKER-USER rule is lost on reboot; the script re-applies
it each run, checks for duplicates, and is silently skipped on macOS/WSL.
Default behaviour (no args): docker compose up -d --build.
All docker compose subcommands can be passed as args (logs, down, etc.).
README Quick Start and Updates sections now reference ./start-gpu.sh.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 00:58:43 +00:00
Claude ce29cc1d30 README: restore iptables as primary DNS fix with isolation clarification
iptables fix is simpler (one command, no 13 GB download) and does not
affect container isolation — adds clarifying note so users understand
it only restores Docker's default outbound DNS behaviour.
Docker helper container kept as fallback option.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 00:55:09 +00:00
Claude d83f94cc24 README: use Docker helper container for offline model download
Replaces 'pip install huggingface-hub' (breaks on PEP 668 / Debian 12+)
with a docker run --rm python:3.11-slim one-liner that downloads directly
into ./data/hf_cache without touching host Python packages.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 00:53:54 +00:00
Claude b63a4f9187 README: simplify AI model offline download — remove iptables option
Replace two-option (iptables vs download) with a single clear offline
download path using huggingface-cli into ./data/hf_cache.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 00:38:45 +00:00
Claude 11772e620c Fix build cache, DNS/model download, and AI Edit error handling
Build / pip layer fixes:
- Add BUILDID ARG to Dockerfile.gpu; pass from docker-compose.gpu.yml build args
  so pip layers can be force-busted without --no-cache:
    BUILDID=$(date +%s) docker compose -f docker-compose.gpu.yml up --build

Model download (DNS-blocked environments):
- Change HF model cache from named volume to ./data/hf_cache bind mount
  so models can be pre-downloaded on the host (no rebuild needed)
- Remove now-unused hf_model_cache named volume
- README: add iptables fix + huggingface-cli offline download instructions

Error handling improvements:
- ai_edit_region: catch ConnectError/Errno-3 → return 503 with exact fix commands
- _require_remote: give actionable message when local_gpu provider fails to load
- _build_provider: catch AttributeError (torch.xpu from wrong diffusers) not just ImportError
- local_diffusion.py: fix docstring to reflect <0.29.0 pin

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 00:14:34 +00:00
Claude 59b26b6d5e Fix diffusers/torch compat, SAM docs, and SelectionActions UX
- Pin diffusers to >=0.28.0,<0.29.0 to avoid AttributeError on torch.xpu
  (diffusers 0.29+ requires PyTorch 2.4 but base image ships 2.1.2)
- Pin transformers to <4.40.0 to match
- README: add SAM offline download troubleshooting for DNS-blocked containers
- SelectionActions panel: 'Selection ready' title + subtitle makes clear
  nothing has fired yet; AI actions show inline description (not just tooltip);
  section labels 'AI Actions' / 'Classic Tools'; scale hint updates live;
  Enter key submits AI edit prompt; _actionCard hover border for clickability

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 23:53:21 +00:00
Claude 59198a6be2 Rewrite README with accurate current state of the project
Old README described the original React/Fabric.js UI and listed
"No local GPU inference" as a non-goal. Updated to reflect:
- miniPaint-based editor with SAM brush selection
- GPU quick-start (nvidia-container-toolkit prereqs, docker-compose.gpu.yml)
- Cloud API quick-start
- GPU tier auto-selection table (FLUX/SDXL/SD by VRAM)
- Full feature list (selection actions, print tools, progress bars)
- Correct clone URL and update commands
- Troubleshooting section

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 17:15:33 +00:00
Claude c8078d4652 Implement complete AI Photo Edit tool with mask-scoped regeneration
This commit implements a full-stack AI photo editing application that
allows users to regenerate only selected areas of images using AI.

Features implemented:
- Frontend (React + Fabric.js):
  * Interactive canvas with selection tools (rectangle, ellipse, lasso)
  * Real-time selection preview and editing
  * Mode toggle (A: patch only, B: patch + context)
  * Feather slider for edge blending (0-50px)
  * Prompt input for AI instructions
  * Edit history viewer with revert capability
  * Responsive UI with dark theme

- Backend (FastAPI):
  * RESTful API for projects and edits
  * SQLite database for metadata storage
  * Image processing pipeline with PIL/OpenCV
  * AI provider interface (pluggable)
  * Support for OpenAI, Stability AI, and mock providers
  * Feathered alpha blending for smooth compositing
  * Complete edit history tracking
  * File-based storage for images and edits

- Image Processing:
  * Patch extraction from bounding boxes
  * Mask generation for all selection types
  * Feathered edge blending
  * Patch compositing back to full image
  * No pixels modified outside selection
  * All edits reversible

- Infrastructure:
  * Docker Compose orchestration
  * Production and development configurations
  * Nginx reverse proxy for frontend
  * Hot-reload support for development
  * Volume persistence for data

Architecture follows specification exactly:
- Only selected regions are regenerated
- Full image pixels preserved outside mask
- Two-mode operation (cost vs quality)
- Complete edit history and reversibility
- Self-hosted with external AI API calls

All components are fully functional and ready for deployment.
2026-01-24 02:58:41 +00:00
outis1one 8cea0a382e Initial commit 2026-01-23 17:50:49 -05:00