Commit Graph
100 Commits
Author SHA1 Message Date
Claude 608d6958b1 Rename remaining EditmaskwithAI references to PaintPlus
Updates README, Docker/Compose comments and container name, install
script banner, about dialog GitHub link, and a script's cd path to
match the repo's new name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011g84QwMKwPMFQPwLVnPrQ1
2026-07-30 23:44:43 +00:00
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 b4a790473c Fix stale UI cache, BEN2 edge quality, and fresh-install permissions
- Serve /dist and /src with Cache-Control: no-cache so browsers always
  revalidate the webpack bundle (it has a fixed filename with no content
  hash, so a stale browser cache was hiding the new Remove Background
  model dropdown after the rebuild).
- Enable BEN2's refine_foreground pass by default - it's the model's own
  documented option for preserving fine/semi-transparent edge detail
  (text borders, light rays) instead of a harder cutout, at a small
  speed cost.
- Make install-local-gpu.sh and bring-up-local-gpu.sh pre-create ./data
  as the invoking non-root user before Docker ever runs, so its daemon
  never gets a chance to auto-create those bind-mount dirs as root.
- Make prefetch-models.sh self-heal a root-owned ./data automatically
  (sudo chown) instead of erroring out with a manual fix-it command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ro4PwQKvSc3CH19LSN21Ht
2026-06-18 17:09:23 +00:00
Claude eca834a7f0 Fix prefetch-models.sh write-permission detection and PEP 668 pip install
The mkdir -p preflight check only verified that data/models and
data/hf_cache could be created, which succeeds vacuously on a directory
that already exists — exactly the case when Docker created ./data as
root on a prior run. Confirmed in practice: U2Net's download reached the
network fine but failed writing the file with Permission denied. Now
test actual writability and point at the one-time fix (chown ./data back
to the calling user) instead of suggesting sudo re-runs that would leave
the ownership problem in place permanently.

Also handle pip's PEP 668 "externally-managed-environment" error
(Debian/Ubuntu 12+) when installing huggingface_hub, retrying with
--break-system-packages — safe here since --user already keeps the
install out of apt-managed system site-packages.
2026-06-18 16:43:55 +00:00
Claude 851e255641 Fix SAM symlink crash and make prefetch-models.sh resilient per-step
download_sam_model.py crashed with an uncaught PermissionError when
data/models/ is root-owned (common after a prior Docker run) and a
non-root host user tries to recreate the convenience sam_model.pth
symlink — observed in the wild, and it aborted the whole prefetch run
before U2Net/BEN2/BiRefNet-HR were ever attempted. Worse, the same
unguarded symlink call sat inside the post-download try/except, so a
successful download could get deleted just because the symlink step
failed afterward. Wrapped symlink creation in a shared helper that
warns and continues instead of raising — the real model file already
satisfies entrypoint.sh's checks regardless of the symlink.

prefetch-models.sh now treats SAM, U2Net, and the HuggingFace models as
independent steps (one failing no longer aborts the rest) and prints a
summary of which steps failed, so a single run gives full diagnostic
signal instead of stopping at the first error.
2026-06-18 16:33:17 +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 781b9e7cdc Fix install-local-gpu.sh running its entire setup body twice
Commit 5c85987 appended a second copy of the toolkit-install/DNS-fix/
GPU-verify steps instead of inserting the new prerequisite-checks
section once. Removed the duplicate, keeping the more informative
GPU-check failure message from the second copy.
2026-06-18 13:57:28 +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 142df74192 Add AI subject replace: file-picker compositing with LAB color matching
- Backend: POST /api/image/replace-subject
  Uses rembg to extract the subject from a source photo, scales it to fit
  the selection mask bounding box (or canvas centre when no selection is
  active), applies a partial LAB color transfer (blend=0.45) so the
  subject's lighting matches the background, then composites the result.
  Also adds POST /api/image/extract-subject for standalone subject extraction.

- Frontend: "Replace with subject from file" button in the selection panel
  (selection_actions.js) — opens a native file picker so no clipboard API
  or HTTPS is required.  Calls the new endpoint with the current SAM mask.

- Frontend: Image > Replace Subject (AI)... menu entry backed by
  modules/image/replace_subject.js — a full dialog with file picker,
  thumbnail preview, and "match background lighting" toggle.  Works with
  or without a prior Smart Select; if a selection exists it confines the
  subject to that region.

https://claude.ai/code/session_01UtrvbisMp1yGu6PqeLmrFr
2026-06-15 15:04:37 +00:00
Claude 5c85987278 install-local-gpu.sh: add prerequisite checks before setup steps
Checks Docker installed + daemon running, NVIDIA driver (nvidia-smi),
and curl. Prints specific install commands for each missing dependency
and exits early with a clear summary rather than failing partway through.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-14 10:06:31 +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 d7683b836a Try Cloudflare DNS first in GPU container; add troubleshooting note
1.1.1.1 uses a different anycast route than 8.8.8.8 so may reach the
container even when Google's servers don't. Falls back to Google if
Cloudflare is also unreachable. If all fail (Errno -3), port 53 UDP is
blocked at the Docker bridge level — comment has the iptables fix.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 23:35:12 +00:00
Claude 80830beae2 Fix scale-selection 500 error (missing BytesIO import) and compact GPU badge
ai_tools.py: add 'from io import BytesIO' — scale_selection and paste
endpoints used BytesIO directly but it was only imported locally in one
unrelated function, causing NameError on every scale call.

provider-badge.js: redesign badge to fit the narrow (~40px) left toolbar.
Was rendering 'GPU · sdxl_offload · Quadro RTX 3000' inline which wrapped
into multiple lines covering tool icons. Now shows a status dot + short
label (SDXL / OAI / Rep…) with all details moved to the hover tooltip.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 23:33:07 +00:00
Claude 34d9f5aafc Fix: guard load_plugins() so helper files without a default export don't crash tool init
selection_actions.js uses named exports only (no default export).
load_plugins() was calling new classObj.default(ctx) on every file in tools/,
causing TypeError which aborted render_main_tools() -> render_main_gui() ->
leaving menu and toolbar blank. Added null guard and per-file try/catch,
matching the defensive pattern already added to load_modules().

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 23:04:10 +00:00
Claude 2a0c414a1c Fix: wrap load_modules() in try/catch so a bad module constructor never kills GUI init
Without this, any constructor throw in any module stops load_modules() mid-loop
and render_main_gui() (which builds the menu) never runs — resulting in a blank
page with no menu. The failing module is now logged to the browser console
instead of silently aborting startup.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 22:43:15 +00:00
Claude 0514f5b67b Fix AttributeError: GpuCapabilities has no attribute 'vram_gb'
main.py referenced info.vram_gb but the field is info.vram_total_gb.
This crashed the FastAPI lifespan hook on every startup when
AI_PROVIDER=local_gpu, causing a restart loop.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 20:08:55 +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 372ab48991 Real per-step progress bars for local GPU inference
Backend:
- local_diffusion.py: add _make_step_cb() that writes step/total_steps/
  progress into _states on every diffusers callback_on_step_end; wired into
  txt2img, inpaint, img2img with TypeError fallback for older diffusers
- ai_tools.py: GET /api/generate/progress SSE endpoint — streams _states
  as JSON array every 200ms so clients get live denoising step counts

Frontend:
- progress_overlay.js: add connectProgressSSE(pipeType, baseUrl) /
  disconnectProgressSSE() — opens EventSource, maps step/total_steps
  to bar percentage (0→85% during denoising, 85→100 for decode/place)
- text_to_image.js: connect SSE before POST, disconnect on done/error
- selection_actions.js: connect SSE for AI edit / asymmetry operations

Result: for local GPU, progress bar shows "Step 12 / 30" with exact fill;
for remote providers and upscale (no step callbacks), shimmer animates.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 16:48:55 +00:00
Claude ee94282753 Add progress overlay and fix txt2img for local GPU
- New progress_overlay.js: animated fullscreen overlay with shimmer bar,
  fake progress creep, Esc-to-cancel, used by all slow AI operations
- text_to_image.js: allow local_gpu provider (was incorrectly blocked);
  show provider/model/VRAM info in dialog; show estimated generation time;
  use progress overlay during generation
- upscale.js: replace alertify.message with progress overlay (90s estimate
  for AI upscale, 10s for Lanczos)
- frame_fit.js: progress overlay for extend mode (AI outpaint ~45s)
- print_prepare.js: progress overlay for full upscale+frame chain (~2 min)
- selection_actions.js: progress overlay for all AI region edits

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 16:37:04 +00:00
Claude 5940e10542 Add print size presets, 18x24 frame, and Prepare for Print workflow
- Add 18x24" to FRAME_SIZES in backend and frontend (frame_fit.js)
- Add 200 DPI option to frame_fit dialog (adequate for large-format prints)
- Add 18x24 portrait/landscape at 200 and 300 DPI to Canvas Size presets (size.js)
- New /api/print/prepare endpoint: chains AI upscale to target DPI then frame-fit
  in one server-side call (avoids round-tripping a large upscaled image)
- New print_prepare.js module: "Prepare for Print" dialog with per-frame quality
  assessment (current effective DPI, needed upscale factor, AI vs Lanczos note)
- Add "Prepare for Print..." to Image menu above "Fit to Frame..."

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 16:25:56 +00:00
Claude a97834fda3 feat: real-world selection actions — scale %, AI edit, clipboard paste
Backend (3 new endpoints under /api/image/):
- POST /api/image/scale-selection  — scale selected object by any % in-place;
  LaMa/OpenCV fills the exposed gap so the scene looks natural
- POST /api/image/ai-edit-region   — AI redraws the masked region via the
  configured inpaint provider (local_gpu / InvokeAI / ComfyUI / OpenAI)
- POST /api/image/paste-into-selection — scales clipboard image to fit the
  selection bounding box, masks it to the selection shape, composites result

Frontend (selection_actions.js + tool integration):
- New SelectionActions panel: fixed bottom-center HUD that appears
  automatically after every SAM selection (click or paint)
- Panel actions: Scale by % (default 3%), Make less symmetrical (AI),
  custom AI Edit prompt, Replace with clipboard, Copy/Cut to layer, Erase
- Both smart_select.js and brush_select.js updated to show the panel,
  add updateLayerWithResult(), and hide panel on clearSelection/on_leave
- brush_select: offerFloatSelection() replaced with richer action panel

Real-world workflows now supported in one click after painting over object:
  "Make this 3% bigger" → scale-selection (LaMa fills gap)
  "Make this less symmetrical" → ai-edit-region with asymmetry prompt
  "Replace this with what I copied" → paste-into-selection

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 16:10:32 +00:00
Claude 9b895673eb feat: GPU capability display in UI + GTX 1060 6GB SDXL fix
Model selection:
- Add sdxl_offload tier (eff_vram ≥ 4.0 GB) for GTX 1060 6GB and Quadro
  6GB cards that were falling through to SD 2.1 despite SDXL fitting with
  model_cpu_offload. Cards with 5.3 GB effective VRAM now get SDXL quality.
- Update _tier_label(), _caps(), _build_warnings() for new tier.

Frontend GPU display:
- api.js: add getGpuStatus() fetching /api/gpu/status
- capabilities.js: add getGpuStatus() export with own LRU cache;
  refreshCapabilities() now also resets GPU status cache
- provider-badge.js: when AI_PROVIDER=local_gpu show green badge with
  GPU name, tier, VRAM, CC, feature flags, and capabilities in tooltip.
  Strip "NVIDIA GeForce" prefix so "GTX 1060 6GB" fits in badge.
- ai_provider_settings.js: add local_gpu to all provider dropdowns;
  show GPU info panel (device, VRAM, CC, features, tier, model table per
  operation) in the settings dialog when a GPU is detected.

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 15:58:13 +00:00
Claude fe4d911a00 Dynamic GPU capability detection: probe CC, VRAM, feature flags, pick best model
Replaces fixed tier table with real hardware probing and dynamic model selection.

gpu_detect.py — complete rewrite:
- Reads torch.cuda.get_device_properties + mem_get_info for actual free VRAM
- Detects: fp16 (CC≥6.0), bf16 (CC≥8.0), fp8 (CC≥8.9 Ada/Hopper),
           int8 (CC≥7.0), tensor_cores (CC≥7.0), xformers presence
- Pre-Pascal (CC<6.0): effective_vram halved (fp32 weights are 2× larger)
- Subtracts 400MB driver overhead from free VRAM before model selection
- _select_txt2img / _select_inpaint / _select_img2img / _select_upscale:
    eff≥20GB  → FLUX.1-schnell (no offload)
    eff≥10GB  → FLUX.1-schnell (model_cpu_offload)
    eff≥7.5GB → SDXL
    eff≥5.5GB → SDXL + attention_slicing
    eff≥3.5GB → SD 2.1
    eff≥2.5GB → SD 2.1-base + attention_slicing
    eff≥1.7GB → SD 1.5
    else      → SD 1.5 + sequential_cpu_offload
- ModelSpec carries: model_id, family, memory_opt, native_res, vram_fp16_gb
- Warnings: old CC, pre-Pascal fp32, fp8 upgrade hint, xformers install tip
- Compatibility shim get_model_ids() retained for existing callers
- infer_spec_from_model_id() auto-detects family from HF_MODEL_* overrides

local_diffusion.py — refactored to use ModelSpec:
- Reads spec from GpuCapabilities.recommended[op] instead of tier table
- FLUX.1-schnell: FluxPipeline / FluxImg2ImgPipeline, 4 steps, guidance=0.0
- SD families: family-aware pipeline class selection (sd15/sd2x/sdxl)
- Memory opts applied per ModelSpec.memory_opt field
- xformers attention enabled automatically when xformers detected

gpu_status.py — richer response:
- Exposes all feature flags (fp16/bf16/fp8/int8/tensor_cores/xformers)
- Returns full ModelSpec per operation (model_id, family, memory_opt, native_res)

ai_tools.py — /api/config exposes:
- gpu_vram_total, gpu_vram_free, gpu_cc, gpu_fp16, gpu_bf16, gpu_fp8,
  gpu_tensor_cores, gpu_eff_vram, local_gpu_warnings

requirements.gpu.txt:
- diffusers bumped to >=0.29.0 (FLUX pipeline added in 0.29)
- transformers bumped to >=4.40.0
- sentencepiece added (FLUX T5 tokenizer)

scripts/gpu_setup.py:
- Prints full model table at startup (op → model_id, family, memory_opt, res)
- Shows all feature flags in one line

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 15:35:37 +00:00
Claude 46b9066bba Handle old/low-VRAM GPUs and document nvidia-container-toolkit requirement
GPU tier table extended:
  ultra   ≥16 GB → SDXL (unchanged)
  high    8-16 GB → SDXL (unchanged)
  medium  4-8 GB → SD 2.x (unchanged)
  legacy  2-4 GB → SD 1.5 (~1.7 GB fp16)  ← new: GTX 970/1060/RX 580 etc.
  minimal <2 GB  → SD 1.5 + sequential CPU offload  ← new: very old/integrated GPUs

gpu_detect.py:
- Detects CUDA compute capability (CC); fp16 disabled for CC < 6.0 (pre-Pascal)
- GpuInfo gains compute_capability and warnings fields
- _make_warnings() emits human-readable warnings for low VRAM and old CC
- model tier fallback updated from 'low' to 'legacy'

local_diffusion.py:
- minimal/legacy tiers use enable_sequential_cpu_offload() + enable_attention_slicing(1)
- target resolution per tier: ultra/high=1024, medium=768, legacy/minimal=512
- .to(device) skipped when sequential CPU offload is active

gpu_status.py:
- Response now includes compute_capability and warnings

docker-compose.gpu.yml:
- Full nvidia-container-toolkit install instructions in header comment
- nvidia-docker2 (legacy) fallback documented as comment block inline
- AMD ROCm swap-in instructions added
- GPU tier table documented in header

scripts/gpu_setup.py:
- Prints compute capability, fp16 status, tier, and model selection at startup
- Prints per-tier warnings (old CC, low VRAM)

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 15:19:01 +00:00
Claude 8fe8498df2 Add local GPU inference: auto-detect GPU, auto-download best diffusion models
Adds AI_PROVIDER=local_gpu — a fully self-contained GPU inference engine
using HuggingFace Diffusers that requires zero InvokeAI/ComfyUI setup.
All existing providers (InvokeAI, ComfyUI, OpenAI, Replicate) remain intact
and can be mixed with local GPU via per-operation overrides.

New features:
- GPU auto-detection (CUDA/NVIDIA, MPS/Apple Silicon, CPU fallback)
- VRAM-tiered model selection:
    ultra ≥16 GB → SDXL inpaint + SDXL base
    high  8-16 GB → SDXL inpaint + SDXL base
    medium 4-8 GB → SD 2.x inpaint + SD 2.1
    low  <4 GB   → SD 2.x (small)
- Auto-download model weights to HuggingFace disk cache at startup
  (background task; first request loads from local disk, not internet)
- LRU pipeline cache evicts oldest GPU pipeline when VRAM limit reached
- Per-operation model overrides via HF_MODEL_INPAINT / HF_MODEL_TXT2IMG etc.
- Optional HF_TOKEN for gated/private HuggingFace models

New files:
- backend/app/services/gpu_detect.py   — GPU detection + tier/model mapping
- backend/app/services/local_diffusion.py — Diffusers provider + LRU cache
- backend/app/routers/gpu_status.py    — GET /api/gpu/status, POST /api/gpu/prefetch
- backend/requirements.gpu.txt         — Diffusers ecosystem deps (GPU only)
- docker-compose.gpu.yml               — NVIDIA GPU compose (one-command startup)
- Dockerfile.gpu                       — pytorch/pytorch:2.1.0-cuda12.1 base image
- scripts/gpu_setup.py                 — Startup GPU info logger

Modified:
- backend/app/config.py                — local_gpu settings added
- backend/app/services/remote_provider.py — local_gpu registered as provider
- backend/app/routers/ai_tools.py      — /api/config exposes GPU tier + caps
- backend/app/main.py                  — GPU router + background prefetch task
- backend/entrypoint.sh                — runs gpu_setup.py at container start
- .env.example                         — local_gpu documented as first option

Quick start with GPU:
  docker compose -f docker-compose.gpu.yml up --build

https://claude.ai/code/session_01WVDg7amsy1TTtxvpku7bcM
2026-06-13 15:08:41 +00:00
Claude 4ba295db37 Fix Fit to Frame: resize canvas to match output dimensions
The fitted image was processed and inserted correctly but the canvas
(config.WIDTH/HEIGHT) was never updated, so the result was clipped to
the original canvas size. Now wraps both new-layer and replace-layer
paths in Prepare_canvas_action + Update_config_action so the canvas
expands (or shrinks) to the target frame size automatically.

https://claude.ai/code/session_017wupXfpjuoSdAqVyak4fJf
2026-06-12 02:20:07 +00:00
Claude 0cf10398bc Fix: also save default_units_short when units toggled in dialogs
Keeps the info-bar unit symbol (px, ", cm, mm) in sync when the user
switches units via the in-dialog toggle rather than Tools > Settings.

https://claude.ai/code/session_017wupXfpjuoSdAqVyak4fJf
2026-06-12 02:13:34 +00:00
Claude f28d8e44b6 Add inches, crop-to-fill, and persistent units to Resize dialog
Resize dialog:
- Units selector (pixels / inches) at the top; switching updates the
  Width/Height placeholders and clears any partially entered values
- New "Crop to fill" checkbox: when both Width and Height are given,
  scales the image with cover-fit (fills target without letterboxing)
  then center-crops — subject looks the same at 5x7, 8x10, 11x14
- resize_layer/resize_gui now honour params.units instead of only
  reading the global default_units setting

Global units persistence:
- Switching units in either Resize or Canvas Size saves the choice to
  default_units so both dialogs open with the same unit next time

https://claude.ai/code/session_017wupXfpjuoSdAqVyak4fJf
2026-06-12 01:50:19 +00:00
Claude 0bf7697916 Update package-lock.json after npm install
https://claude.ai/code/session_017wupXfpjuoSdAqVyak4fJf
2026-06-12 01:13:46 +00:00
Claude 35932743fc Add inches unit, print size presets, and resize-crop to Canvas Size dialog
- Units selector (pixels/inches) directly in the dialog; switching live-converts
  the width/height fields so you can type e.g. 5 / 7 without mental math
- Six print-size presets at 300 DPI added to the Resolution dropdown:
  5x7, 8x10, and 11x14 in both Portrait and Landscape orientations
- New "Resize & crop image" checkbox: when enabled, image layers are scaled
  with cover-fit (fills the target canvas, no letterboxing) and center-cropped
  so the subject stays proportionally the same across all three print sizes

https://claude.ai/code/session_017wupXfpjuoSdAqVyak4fJf
2026-06-12 01:13:13 +00:00
Claude aebd24624a Fix AI Edit tool events, add icon, move color swatch to toolbar bottom
ai_edit.js:
- Extend Base_tools_class and add load() + default_events() so mouse
  events actually wire up (was the root cause of tool not working)
- Use get_mouse_info() for coordinate mapping instead of manual
  clientX/Y math — consistent with all other miniPaint tools
- Fix _mouseToImage() to use mouse.x/y (already in image coords)
  and correct display-scale for overlay brush rendering
- mousedown/mousemove/mouseup now guard on config.TOOL.name

ai_edit.svg: new icon (brush + sparkle star) for the left toolbar

layout.css: add .ai_edit:after CSS rule for the icon

main.js:
- Collapse right-panel Colors section by default (respects saved cookie
  so user preference persists)
- Mount compact foreground/background color swatches at the bottom of
  the left toolbar; click either square to toggle the full color picker
  open/closed; syncs live with config.COLOR every 250ms

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-12 00:42:53 +00:00
Claude 065495e665 Fix startup crash: replace sklearn k-means with pure numpy implementation
sklearn was not installed in the container, causing ModuleNotFoundError on
import of ai_tools.py and preventing the server from starting.

Replaced with a self-contained numpy k-means++ implementation:
- k-means++ seeding for better initial centers
- 20-iteration Lloyd's algorithm
- Same output: hex colors sorted by cluster frequency

No new dependencies required.

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-11 23:24:00 +00:00
Claude 54be280b5b Enhance eyedropper with live Pantone matching tooltip
pick_color.js: on hover shows a floating tooltip with:
  - 40px color swatch of the sampled pixel
  - Hex (#RRGGBB), RGB, and HSL values
  - Nearest Pantone name and swatch from the database
  - ΔE value (CIE76 color distance in LAB space)
  - Quality badge: Excellent (<2) / Good (2-5) / Fair (5-10) / Poor (>10)
  - Warning note when ΔE > 10 (color cannot be faithfully printed as Pantone)
  Click copies hex to clipboard and sets as active color (existing behavior).

color_utils.js: hexToRgb, rgbToHsl, sRGB→XYZ→CIE LAB conversion (D65),
  CIE76 deltaE, nearestPantone() (scans all ~350 entries, returns best match).
  Pantone database is pre-converted to LAB at module load for fast scanning.

pantone_colors.js: ~350 representative PMS colors across reds, oranges,
  yellows, greens, teals, blues, purples, magentas, browns, grays, black/white.
  Hex approximations from open-source Pantone datasets (not official Pantone data).

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-11 01:52:23 +00:00
Claude d2273017fd Add Auto-Enhance, Color Palette, History Panel, Align, Text Presets
Auto-Enhance (Image menu):
  POST /api/enhance — gray-world white balance, CLAHE contrast on L channel,
  saturation boost ×1.15 in HSV, unsharp mask; all blended by strength slider
  Frontend: strength selector (25/50/75/100%), keep-original option

Extract Color Palette (Image menu):
  POST /api/extract-colors — k-means on 150×150 thumbnail, returns N dominant
  colors sorted by cluster size. Frontend: floating swatch panel, click=copy
  hex, shift+click=set as active color, toggle on/off.

History Panel (Edit menu, Ctrl+H):
  Pure frontend — reads app.State.action_history and action_history_index,
  renders clickable list of past actions (newest first), click any step to
  undo/redo to that point. Auto-refreshes every 800ms while open.

Align to Canvas (Layer menu):
  Floating toolbar with 7 alignment buttons: center H, center V, center both,
  align left/right/top/bottom edges. Uses Update_layer_action for undo support.

Add Text (Generate menu):
  6 styled presets (Heading, Subheading, Body, Caption, Quote, Bold Label)
  shown as live-rendered previews in the dialog. Click a preset to insert a
  text layer with the correct font/size/weight/color pre-applied.

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-11 01:41:20 +00:00
Claude 78341297a2 Add TIFF (CMYK/Multilayer) and PDF (RGB/CMYK) export formats
- tiff-writer.js: pure-JS multipage TIFF encoder with RGBA and CMYK
  color modes; RGB→CMYK conversion; one IFD per layer for multilayer
- pdf-writer.js: pure-JS PDF-1.4 writer; RGB pages use browser JPEG
  encoding (DCTDecode); CMYK pages embed raw DeviceCMYK pixel data;
  multipage support (one page per visible layer)
- save.js: adds TIFF (CMYK), TIFF (Multilayer), PDF (RGB), PDF (CMYK)
  to the export dialog; CMYK types bypass the separated-layers loop and
  composite with a white background before color conversion
2026-06-10 19:26:14 +00:00
Claude 3746c02d44 Add SAM click-to-select with brush refinement in AI Edit tool
Backend:
- sam_service.py: auto-downloads SAM ViT-B (~375 MB) on first use with
  progress tracking; loads model to CUDA/MPS/CPU; predict_points() takes
  multi-point prompts (include/exclude labels) and returns best mask
- POST /api/segment/point: SAM point-prompt endpoint; returns mask PNG
- GET  /api/segment/install-status: poll download progress
- POST /api/segment/install: explicit trigger (also auto on first click)
- main.py: pre-download SAM on startup alongside NCNN

Frontend (ai_edit.js):
- Click mode (default): click object → SAM generates mask instantly
  Alt+click → subtract (deselect over-selected area)
  Multiple clicks accumulate for multi-object or refinement
- Brush + / Brush − modes: paint to add or erase from SAM mask by hand
- If SAM model is still downloading on first click: inline progress bar,
  user retries the click when done
- Unified action bar: Erase | Replace (inline prompt) | Upscale | Expand | Clear
- All modes share the same mask canvas; SAM and brush are fully composited

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-10 18:18:33 +00:00
Claude 1132656370 Replace scattered AI tools with single unified AI Edit tool
Before: 4 separate tools (ai_inpaint, ai_lama_erase, ai_smart_inpaint,
ai_replace_selection) with no clear relationship, buried in toolbar.

After: one "AI Edit" brush tool. Paint mask → floating action bar appears:
  Erase    — LaMa removes masked content, no prompt needed
  Replace  — inline prompt reveals in-place ("make her smile" / "replace
             with a wolf") → calls /api/inpaint/remote
  Upscale  — delegates to existing upscale module
  Expand   — delegates to existing outpaint module
  Clear    — wipe mask and start over

Brush size controlled by tool attributes (5–200px).
Red overlay gives immediate visual feedback while painting.
Floating panel appears as soon as first brush stroke is made.

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-10 16:42:10 +00:00
Claude 717f482987 Skip NCNN install on headless/no-Vulkan machines
- Add _vulkan_available(): checks /dev/dri/renderD* on Linux, assumes
  true on macOS/Windows; set REALESRGAN_NCNN=force to override
- Add _test_ncnn_binary(): test-runs the binary after install and checks
  stderr for "no vulkan" — marks skipped if Vulkan init fails at runtime
- ensure_ncnn_installed() now returns early with state=skipped when no
  Vulkan detected, avoiding a wasted ~30MB download on CPU-only servers
- Recommend PyTorch CPU when available on headless (AI quality, slow but
  works); Lanczos as final fallback
- Frontend: handle state=skipped immediately (no polling needed), show
  brief informational toast; show "Headless server" note in dialog

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-10 00:50:09 +00:00
Claude ed2a0d7f0c Auto-install Real-ESRGAN NCNN Vulkan binary on first use
- upscale.py: add InstallStatus dataclass + ensure_ncnn_installed() async
  function that downloads and extracts the NCNN binary for the current
  platform (Linux/macOS/Windows), tracks progress (0-100%), and busts the
  caps cache when done
- main.py: trigger ensure_ncnn_installed() as a background task on app
  startup when no AI upscaler is detected
- print_tools.py: /upscale/available triggers install task when no AI
  upscaler found; new GET /upscale/install-status endpoint for polling
- upscale.js: if no AI upscaler on open, poll install-status showing a
  progress bar notification, then refresh caps and proceed when done

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-09 18:38:45 +00:00
Claude cea9ee9d6c Smart upscale: auto-detect hardware and pick best Real-ESRGAN path
Detection priority (probed once, cached):
  1. Real-ESRGAN PyTorch + CUDA GPU   → fastest, best quality
  2. Real-ESRGAN PyTorch + Apple MPS  → fast on Apple Silicon
  3. Real-ESRGAN NCNN Vulkan binary   → fast on any GPU via Vulkan (no CUDA needed)
  4. Real-ESRGAN PyTorch CPU          → works, slow (warned in UI)
  5. Lanczos                          → always available, instant fallback

Backend:
- services/upscale.py: full capability probe (probe_upscale_capabilities),
  implementations for PyTorch (CUDA/MPS/CPU auto-device) and NCNN binary,
  upscale_sync() resolves method with fallback chain,
  async upscale_image() runs in thread pool
- print_tools.py: /api/print/upscale uses new service; method="auto" by default;
  GET /api/print/upscale/available returns full capability map with device info
  and recommended_label; POST /api/print/upscale/refresh-caps busts cache
  without restart (useful after installing NCNN binary into container)

Frontend:
- upscale.js: fetches capability map on first open; builds method selector showing
  only available options; labels recommended method with ★; shows device info
  (CUDA/MPS/CPU/NCNN) in dialog; maps display label back to method key on submit;
  shows actual method used in success toast and undo history entry

Scripts:
- scripts/download_realesrgan.py: downloads NCNN Vulkan binary for current platform
  (Linux/macOS/Windows) to /app/data/models/realesrgan/; makes executable;
  run inside container or locally

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-09 18:32:32 +00:00
Claude 40396b72a0 Add Fit to Frame and Upscale (print tools)
Backend — new /api/print/* router:
- POST /api/print/frame-fit: fit image to 4x6/5x7/8x10/11x14/16x20/20x24/24x36
  and square sizes (4x4/8x8/12x12) at configurable DPI.
  Three modes:
    crop   — center-crop to aspect ratio, Lanczos scale to print res (no AI)
    extend — scale to fill one dimension, AI-inpaint the gap; mirror-fill fallback
    smart  — auto: extend if gap < 15% of frame dimension, else crop
  Auto-detects orientation from image shape; respects explicit portrait/landscape.
- POST /api/print/upscale: Lanczos scale (always) or Real-ESRGAN (if installed)
- GET  /api/print/frame-sizes: frame catalogue with pixel dimensions at 300dpi
- GET  /api/print/upscale/available: reports whether Real-ESRGAN is installed

Frontend:
- modules/image/frame_fit.js: dialog with frame size, orientation, mode, DPI,
  optional extend prompt; shows current image size; result as new layer option
- modules/image/upscale.js: dialog with scale factor (1.5–4×), method selector
  (auto-hides AI option if Real-ESRGAN not available); result as new layer option
- config-menu.js: Fit to Frame... and Upscale... added under Image menu

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-09 18:21:22 +00:00
Claude d01c11f948 Add per-operation AI provider routing
Each operation (inpaint, txt2img, img2img, outpaint) can now use a different
provider. Resolution order: per-op override → global AI_PROVIDER default.

Example: txt2img→openai, inpaint→invokeai, everything else→invokeai default.

Backend:
- config.py: add AI_PROVIDER_INPAINT / TXT2IMG / IMG2IMG / OUTPAINT settings
- remote_provider.py: get_remote_provider(operation) resolves override then default;
  _build_provider() extracted as shared factory; _OP_FIELD maps op→setting name
- ai_tools.py: each endpoint passes its operation to _require_remote();
  GET /api/config runs per-op health checks concurrently, returns operations map
  and overrides; POST /api/config accepts and applies per-op override fields

Frontend:
- ai_provider_settings.js: four new selects (inpaint/txt2img/img2img/outpaint);
  persists to localStorage and sends per-op fields to POST /api/config
- provider-badge.js: shows override summary (e.g. "invokeai · txt2img→openai")
  and per-op health in tooltip
- .env.example: document per-op override env vars with examples

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-09 18:14:12 +00:00
Claude b2a12c356f Add generative panels, provider settings UI, and credits
Frontend:
- tools/ai_replace_selection.js: use any selection → remote inpaint with prompt
- modules/generate/text_to_image.js: Text → Image dialog (new layer or replace canvas)
- modules/generate/outpaint.js: Expand Canvas in any direction via remote provider
- modules/tools/ai_provider_settings.js: in-app provider config (OpenAI / InvokeAI /
  ComfyUI / Replicate); persists to localStorage, pushes to POST /api/config at runtime
- config.js: register ai_replace_selection tool
- config-menu.js: add Generate menu (Text→Image, Outpaint); AI Provider Settings under Tools
- modules/help/about.js: updated credits (LaMa, rembg, SAM, InvokeAI, ComfyUI, OpenAI)
- api/capabilities.js: add refreshCapabilities() for post-save cache invalidation

Backend:
- routers/ai_tools.py: POST /api/config — apply provider settings at runtime
  without restart (session-scoped, non-persistent; .env for permanence)

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-09 17:54:44 +00:00
Claude 27261c4ef4 Add LaMa magic eraser, remote provider abstraction, and AI tool infrastructure
Backend:
- requirements.txt: add simple-lama-inpainting, rembg[gpu]; upgrade opencv to 4.10+
- app/config.py: add InvokeAI (url, model) and ComfyUI (url, model) settings; OPENAI_MODEL
- app/services/local_inpaint.py: LaMa, OpenCV, rembg wrappers (auto GPU/CPU)
- app/services/remote_provider.py: abstract RemoteAIProvider + OpenAI, InvokeAI, ComfyUI drivers
- app/routers/ai_tools.py: new /api/* endpoints — /erase, /inpaint/lama, /inpaint/fast,
  /background/remove, /inpaint/remote, /generate/txt2img, /generate/img2img,
  /generate/outpaint, GET /config (capability flags)
- app/main.py: register ai_tools router

Frontend:
- services/api.js: add erase(), textToImage(), imageToImage(), remoteInpaint(), getConfig()
- api/capabilities.js: lazy-fetch /api/config singleton; hasRemote() helper
- tools/ai_lama_erase.js: brush-paint mask → LaMa erase → apply to layer
- tools/ai_smart_inpaint.js: brush mask + dialog (Fast/Quality mode + prompt) → inpaint
- core/components/provider-badge.js: shows active provider + health in toolbar
- config.js: register ai_lama_erase and ai_smart_inpaint tools
- main.js: mount provider badge on load
- .env.example: document InvokeAI, ComfyUI, OpenAI provider settings

https://claude.ai/code/session_01B58MaJCU1R6KwBDJCp8AfN
2026-06-09 17:42:48 +00:00
Claude 871fc696f5 Fix U2Net, alertify dialogs, and improve AI Paint workflow
- Switch U2Net from onnxruntime to OpenCV DNN to avoid
  "cannot enable executable stack" error in Docker
- Add alertify dialog styling to fix white text on white
  background issue in popups
- Add offerFloatSelection() to AI Paint that prompts user
  after selection to move/scale it (Canva-like workflow)
- Auto-switch to Select tool after floating selection

https://claude.ai/code/session_01CLedz6CanT9t46KBvng3vz
2026-01-28 13:23:49 +00:00
Claude ed491ab9ba Fix AI Paint tool processing state and use full U2net model
- Fix brush_select isProcessing flag not resetting after first use
  (reset in on_leave() when switching tools)
- Add onnxruntime dependency for U2net background removal
- Use full U2net model (176MB) instead of lightweight for better quality

https://claude.ai/code/session_01CLedz6CanT9t46KBvng3vz
2026-01-28 03:05:23 +00:00
Claude e26c914483 Fix selection tools, add float selection, aspect ratio lock, U2net auto-download
- Fix brush_select and smart_select mask scaling to match layer dimensions
- Add "Float Selection" feature to Select tool - when switching to Select
  with an active AI selection, offers to copy it to a movable layer
- Add aspect ratio lock toggle (🔗 button) in layer details panel
- When locked, changing width auto-updates height and vice versa
- Add U2net model auto-download - will download lightweight u2netp.onnx (~4MB)
  automatically if no model found
- Improve error messages for background removal
- Register on_activate for select tool in config

Workflow: Select object with AI tool → Click Select tool → "Float" selection
→ Move/scale the floated layer freely

https://claude.ai/code/session_01CLedz6CanT9t46KBvng3vz
2026-01-27 22:59:22 +00:00
Claude 549a1a4e82 Fix AI tools and My Library, add U2net background removal
- Fix My Library: Add CSS styling for library browser, items now visible
- Integrate My Library into Shapes tool with tabbed interface
- Improve AI Inpaint: Add transform mode for scaling/sizing selections
- Add helpful guidance explaining inpaint vs transform modes
- Add U2net as alternative background removal (avoids rembg issues)
- Create U2net model definition and download script
- Improve Caddyfile with multiple options and troubleshooting guide

Note: Brush Select (AI Paint) tool was already implemented and working.

https://claude.ai/code/session_01CLedz6CanT9t46KBvng3vz
2026-01-27 22:29:35 +00:00
Claude 41598722f1 Disable rembg to fix build - numpy version conflict
rembg>=2.0.70 has an incompatible dependency chain:
- rembg requires scikit-image>=0.26.0
- scikit-image 0.26+ pulls in numpy 2.x
- opencv-python-headless 4.9.0.80 was compiled for numpy 1.x
- Runtime crash: "numpy.core.multiarray failed to import"

Fix: Revert to known-working numpy<2 stack:
- numpy<2.0.0 (explicit pin)
- Pillow 10.x (compatible with numpy 1.x)
- torch 2.1.2 / torchvision 0.16.2 (numpy 1.x compatible)
- Remove rembg and onnxruntime

Background removal endpoints will return 500 with "rembg not installed"
message (code already handles this gracefully).

To re-enable rembg in future: update opencv-python-headless to 4.10+
which supports numpy 2.x.

https://claude.ai/code/session_01MYpjNQXD1fZE4gCweGU4QQ
2026-01-27 17:55:54 +00:00
Claude 62ad349a83 Update torch/torchvision for numpy 2.x compatibility
scikit-image 0.26+ (required by rembg) needs numpy 2.x compatible
packages. Updated torch from 2.1.2 to 2.4+ and torchvision from
0.16.2 to 0.19+ which officially support numpy 2.x.

https://claude.ai/code/session_01MYpjNQXD1fZE4gCweGU4QQ
2026-01-27 17:37:07 +00:00
Claude b4fae0909c Remove pinned numpy and scikit-image to fix rembg dependency resolution
rembg>=2.0.70 requires scikit-image>=0.26.0, which conflicted with
the pinned scikit-image==0.22.0. Instead of pinning specific versions,
let pip resolve compatible versions automatically based on rembg's
requirements.

Also removed numpy pin as it may conflict with torch/rembg dependencies
- pip will select a compatible version.

https://claude.ai/code/session_01MYpjNQXD1fZE4gCweGU4QQ
2026-01-27 17:36:30 +00:00
Claude e902ceb0a8 Fix Pillow version to match rembg>=2.0.70 requirements
rembg 2.0.70+ requires Pillow>=12.1.0,<13.0.0 which conflicted with
the pinned Pillow==10.2.0. Updated to use the version range that
satisfies rembg while remaining compatible with scikit-image and
torchvision (both have no upper bound on Pillow).

https://claude.ai/code/session_01MYpjNQXD1fZE4gCweGU4QQ
2026-01-27 17:19:06 +00:00
Claude bca0eeb259 Remove execstack from Dockerfile (not available in Debian trixie) 2026-01-27 14:57:20 +00:00
Claude 2ab9ed7559 Upgrade rembg to use BiRefNet model (state-of-the-art)
- Use onnxruntime>=1.17.0 (fixed executable stack issues, no execstack needed)
- Use rembg>=2.0.70 with BiRefNet model support
- Update all remove-background endpoints to use birefnet-general model
- BiRefNet provides better edge detection and matting quality than u2net
- Falls back to default model if BiRefNet unavailable
2026-01-27 14:34:28 +00:00
Claude 44bc5ed2f5 Fix rembg/onnxruntime Docker build issue
- Use onnxruntime 1.14.1 (older version without executable stack requirement)
- Make rembg pre-download optional (won't fail build if onnxruntime has issues)
- Remove Background will be disabled if rembg can't load
2026-01-27 14:08:16 +00:00
Claude 8087d6967a Add My Library for reusable assets (clip art, templates)
- Save layer or selection to personal library
- Browse library with category grouping and thumbnails
- Insert assets as new layers (double-click or Insert button)
- Delete unwanted assets
- Export library to JSON for backup
- Import library from JSON backup
- Assets stored in browser IndexedDB (persistent)
- Categories: General, Shapes, Borders, Icons, Templates, etc.
2026-01-27 13:15:58 +00:00
Claude 4d4947df13 Add selection-based effects (invert, adjust, greyscale)
- New Image > Selection Effects submenu
- Invert Selection: Invert colors only within selected area
- Adjust Selection: Brightness/contrast/gamma on selection only
- Greyscale Selection: Convert just the selected area to greyscale
- All effects work with any selection tool (Smart Select, Brush Select, etc.)
- Useful for CNC depth maps where specific objects need different treatments
2026-01-27 13:09:06 +00:00
Claude 1be13d3620 Add layer scaling, greyscale effect, and context menu
- Fix onnxruntime version (1.15.1) to avoid executable stack issue
- Add Layer Scale module (Layer > Scale Layer or 'S' button)
- Add Greyscale effect with multiple methods (luminosity, average, etc.)
- Add right-click context menu on layers with common operations
- Add Scale button to layers panel toolbar
2026-01-27 12:51:11 +00:00
Claude a1dd81b981 Fix onnxruntime executable stack error in Docker build
The onnxruntime library requires an executable stack which is blocked
by security restrictions in Docker containers. This adds execstack tool
and uses it to clear the executable stack flag after pip install.

https://claude.ai/code/session_01AGoPJaXqdJnnuxtmSv6NLR
2026-01-27 04:49:32 +00:00
Claude d9fea955fc Fix rembg error handling in Dockerfile 2026-01-27 04:27:53 +00:00
Claude a9a2b7bf04 Add Canva-style Brush Select tool with SAM AI
- New tool: Paint/brush over objects to select them
- AI (SAM) detects actual object boundaries from brush strokes
- Collects sample points along brush path, sends to SAM
- Combines multiple masks for multi-object selection
- Shift+brush to add to existing selection
- Full cut/copy/delete support with mask-shaped results
- Visual feedback: brush stroke preview, sample points, marching ants
2026-01-27 04:22:44 +00:00
Claude d2f7b69dc7 Fix selection tools and improve UI/UX
- Fix cut/copy to preserve mask shape with transparency
- Add missing CSS icons for magic_wand, lasso, ellipse_select tools
- Fix toast messages styling (visible on dark theme)
- Update AI Inpaint to work with all selection tools
- Change tab title to +miniPaint
- Add DNS config to docker-compose for external API access
2026-01-27 03:09:55 +00:00
Claude 22d9f767a8 Add Remove Background feature using AI (rembg)
Frontend:
- Added "Remove Background (AI)" to Image menu
- Created remove_background.js module with dialog options
- Added removeBackground method to API service

Backend:
- Added /tools/remove-background-base64 endpoint for miniPaint frontend
- Uses rembg library for AI-powered background removal

Features:
- Automatically detects main subject and removes background
- Option to create as new layer or replace current
- Enables transparency mode after removal
- Works with any image layer
2026-01-27 00:47:22 +00:00
Claude f650ec3019 Add selection tools: Magic Wand, Lasso, Ellipse Select
New Selection Tools:
- Magic Wand: Click to select by color similarity (like GIMP)
  - Configurable tolerance (0-100%)
  - Contiguous or global mode
  - Shift+Click to add to selection

- Lasso: Freehand selection by drawing
  - Draw around area to select
  - Shift+Draw to add to selection

- Ellipse Select: Draw elliptical/circular selections
  - Drag to create ellipse
  - Shift+Drag for perfect circle
  - Alt+Drag to draw from center

Smart Select Improvements:
- Fixed copy/cut to layer errors
- Added Shift+Click for multi-select (additive selection)
- All operations use proper layer action system

All selection tools support:
- Ctrl+C: Copy selection to new layer
- Ctrl+X: Cut selection to new layer
- Delete: Delete selected area
- Escape: Clear selection
- Marching ants animation on selection edge
2026-01-27 00:39:40 +00:00
Claude 53225e9e05 Improve SAM selection with mask contour and layer operations
- SAM selection now shows actual mask contour instead of bounding box
- Added marching ants animation on the actual mask edge
- Added keyboard shortcuts:
  - Ctrl+C: Copy selection to new layer
  - Ctrl+X: Cut selection to new layer (removes from original)
  - Delete: Delete selected area
  - Escape: Clear selection
- Removed eye catalog download from startup (was failing with 429)
2026-01-27 00:00:16 +00:00
Claude cfe487e2ed Fix smart select visualization and inpaint API
Frontend:
- Fix smart_select.js to properly render mask overlay
- Add marching ants border around selection
- Calculate selection bounds from mask
- Trigger re-render after mask is loaded

Backend:
- Fix inpaint endpoint to call edit_image() instead of inpaint()
- The AI providers use edit_image() method, not inpaint()
2026-01-26 18:26:12 +00:00
Claude f0ea7df6b7 Fix API base URL for unified container setup 2026-01-26 18:04:27 +00:00
Claude e0eb65810a Fix Docker build for miniPaint frontend
- Update main Dockerfile to copy all miniPaint static files:
  - index.html
  - dist/ (webpack bundle)
  - images/ (icons and assets)
  - src/css/ (stylesheets)
- Update backend main.py to conditionally mount static directories
  - Checks if each directory exists before mounting
  - Supports both React (assets/) and miniPaint (dist/, images/, src/) structures
2026-01-26 17:43:14 +00:00
Claude bf83ecc8ad Add SAM Smart Select and AI Inpaint tools to miniPaint
New features:
- Smart Select tool: Click to select objects using SAM (Segment Anything)
- AI Inpaint tool: Edit selected regions with text prompts

Changes:
- frontend/src/js/tools/smart_select.js: SAM-powered selection tool
- frontend/src/js/tools/ai_inpaint.js: AI inpainting with prompt dialog
- frontend/src/js/services/api.js: API service for backend communication
- frontend/src/js/config.js: Register new tools
- frontend/src/css/layout.css: Tool icon styles
- frontend/images/icons/: SVG icons for new tools
- backend/app/routers/tools.py: New base64 API endpoints
- frontend/Dockerfile: Updated for miniPaint build
- frontend/nginx.conf: Added /api prefix proxy
2026-01-26 17:34:20 +00:00
Claude 487f52a616 Fix undefined variable references in ImageCanvas
ROOT CAUSE: ImageCanvas referenced props that don't exist:
- activeTool, onSmartSelect, onColorSelect were used but never declared
- selectionMode checked for 'smart'/'color' but App passes advancedToolMode with 'smart-select'/'color-select'

Changes:
- Update mode checking to use advancedToolMode instead of selectionMode for smart/color select
- Replace onSmartSelect/onColorSelect calls with onAdvancedToolClick
- Fix useEffect dependency array to reference actual props
- Add missing state/refs: currentZoom, imageRef, baseScaleRef, isDrawingRef
- Add zoom control buttons to canvas UI
- Fix tool mode indicator to check advancedToolMode
2026-01-26 13:39:24 +00:00
Claude c12e8c9508 Fix missing onZoomChange prop declaration in ImageCanvas 2026-01-26 05:45:44 +00:00
Claude 9cd8a5badb Fix remaining onZoomChange references to use ref pattern 2026-01-26 05:23:01 +00:00
Claude b185cd549c Fix onZoomChange reference error - use ref to avoid closure issues 2026-01-26 05:14:11 +00:00
Claude 2c9211355d Fix black screen issue - ensure canvas has dimensions before loading image 2026-01-26 05:00:42 +00:00
Claude 09c4f71c0a Improve ImageCanvas - zoom, selection fixes, tool modes
- Add zoom support via prop (scales image around center)
- Fix selection interaction: clicking on selection transforms, clicking elsewhere creates new
- Use refs for state accessed in event handlers (fixes stale closure issue)
- Add smart select mode (clicks call onSmartSelect with image coordinates)
- Add color select mode placeholder
- Add pan mode with cursor feedback
- Add move mode for manipulating selections
- Use dashed blue selection style (more visible)
- forwardRef to expose canvas methods
2026-01-26 00:57:56 +00:00
Claude 9922b2a03e GIMP-like UI overhaul - toolbar, sidebar, full-width canvas
- Redesign layout: left toolbar, center canvas, right sidebar
- Add vertical tool strip with keyboard shortcuts (V, R, E, F, W, B, G, Z, H)
- Collapsible sidebar panels: Tool Options, AI Edit, Quick Actions, Eyes, Layers, History
- Canvas now fills available space with checkerboard background
- Add zoom controls in status bar
- Add menu bar with New, Save, Reset
- Remove old multi-column layout
2026-01-26 00:56:28 +00:00
Claude 2a5b50ee4c Consolidate to single container, remove nginx
- Create unified Dockerfile with multi-stage build (Node + Python)
- FastAPI now serves React static files directly
- Remove frontend service and nginx dependency
- Simplify docker-compose to single service
- All routes work without proxy configuration
2026-01-25 23:40:51 +00:00
Claude a59887f8c5 Add /tools proxy location to nginx config
Fixes 405 errors on /tools/* POST endpoints (smart-select,
remove-background-to-layer, etc.) by proxying to backend.
2026-01-25 23:36:32 +00:00
Claude d95b95e234 Wire Smart Select, Color Select, fix layer buttons, add zoom
Frontend changes:
- Wire Smart Select and Color Select to canvas click handlers
- Add externalSelection prop to ImageCanvas for displaying AI-generated selections
- Add zoom controls (mouse wheel + buttons) to ImageCanvas
- Fix layer buttons (New Layer, Delete, Duplicate) with proper handlers
- Lift advancedToolMode state to App.jsx for coordination between components
- Add tool mode indicator overlay on canvas

Backend changes:
- Update smart-select endpoint to return JSON with polygon and bbox data
- Update color-select endpoint to return JSON with polygon and bbox data
- Add _mask_to_polygon helper function using OpenCV contour detection
- Add cv2 and base64 imports to tools.py

API changes:
- smartSelect and colorSelect now return { polygon, bbox, mask_base64 }
2026-01-25 20:49:52 +00:00
Claude df4ddc2d8c Automate SAM download and fix database path issues
- Fix database path mismatch: download_sample_eyes.py now uses
  ai_photo_edit.db instead of photoedit.db
- Add init_database.py script to initialize DB before eye import
- Add AUTO_DOWNLOAD_SAM=true environment variable (default: enabled)
- Update entrypoint.sh to:
  1. Initialize database first
  2. Auto-download SAM model (~375MB) on first startup
  3. Then import eyes (now works since DB exists)
- Update path detection to work in both Docker and local environments
2026-01-25 20:28:57 +00:00
Claude a28b889728 Add git to Dockerfile for segment-anything install 2026-01-25 18:25:42 +00:00
Claude 8b96c86a94 Add local SAM model support for offline Smart Select
- Add torch, torchvision, segment-anything to requirements
- Create download_sam_model.py script to fetch SAM checkpoint
- Update tools.py to use local SAM with Replicate API fallback
- Add SAM model check to entrypoint.sh with helpful instructions
- Model persists in /app/data/models via Docker volume mount
2026-01-25 18:15:07 +00:00
Claude 28e842e190 Add auto-populate eyes on startup and comprehensive .env docs
- Create entrypoint.sh that auto-downloads sample eyes on first run
- Update Dockerfile to use entrypoint script
- Rewrite .env.example with step-by-step setup instructions
- Add detailed troubleshooting section
- Clarify which models work for inpainting vs text-to-image
2026-01-25 18:06:09 +00:00
Claude 4c2574ace4 Add SAM (Segment Anything) via Replicate API and update Docker
- Implement SAM object selection via Replicate API
  - Click on any object to select it with AI precision
  - Falls back to flood-fill if Replicate API unavailable
- Update Dockerfile for rembg dependencies
  - Add required system libraries (libsm6, libxext6, etc)
  - Pre-download rembg model during build
  - Create data directories for models and patches
2026-01-25 16:24:08 +00:00
Claude 909bb41f8a Add advanced editing features: layers, background removal, smart selection
Backend:
- Add /tools router with background removal, smart select, color select
- Add rembg dependency for AI background removal
- Add layer management API (list, flatten)
- Fix transparency preservation in blend_patch (veil collapse fix)
- Preserve alpha channel when reverting/resetting images

Frontend:
- Add AdvancedTools panel with background removal, smart select, color select
- Add Layers panel with drag-to-reorder, visibility toggle, flatten
- Add toolsApi for new backend endpoints
- Make right panel scrollable for additional controls

This adds "Photoshop light" capabilities:
- Remove background and create layer
- Smart object selection (click to select)
- Color selection with tolerance
- Layer system with compositing
2026-01-25 15:20:11 +00:00
Claude 7a86d53c88 Add script to download sample eye images for catalog
Creates scripts/download_sample_eyes.py that:
- Downloads public domain classical sculpture images from Wikimedia
- Creates patch records in database
- Generates thumbnails
- Populates the Eye Catalog with starter content
2026-01-25 15:08:50 +00:00
Claude 2813d930b0 Fix UX issues and add Eye Catalog UI
Fixes:
- Remove scale limit to allow image to fill canvas
- Fix Lasso tool by using Polygon instead of Polyline
- Remove duplicate Clear Selection button
- Fix Undo/Redo dependencies with useCallback

New Features:
- Eye Catalog UI for browsing and applying saved eyes
- Upload new eyes to catalog
- Apply eyes to selected areas with feathering
- Delete eyes from catalog
2026-01-25 05:17:10 +00:00
Claude d898106368 Add core editing UX improvements
- Make canvas use full viewport height for larger image display
- Add download button to export edited images
- Implement Undo/Redo with Ctrl+Z / Ctrl+Y keyboard shortcuts
- Add transform controls for selections (move, resize, rotate)
- Add warn on reload to prevent data loss
- Make project naming optional, auto-generate from filename
2026-01-25 04:51:45 +00:00
Claude 8dfa7d3e17 Increase nginx client_max_body_size to 50MB for image uploads 2026-01-25 03:09:03 +00:00
Claude 75e04f722d Fix frontend API to use relative URLs through nginx proxy
Changed default API_BASE_URL from 'http://localhost:8000' to empty string
so requests go through nginx proxy instead of trying to connect directly.
2026-01-25 02:53:50 +00:00
Claude 6238318f9b Add classic eye image assets and import scripts
- Generate 18 classic eye variants in 3 styles (realistic, anime, cartoon)
  with 6 colors each (blue, green, brown, hazel, grey, amber)
- Add scripts for generating, converting, and importing eyes:
  - generate_classic_eyes_ppm.py: Generate PPM images (no dependencies)
  - download_classic_eyes.py: Full-featured generator with PIL
  - startup_import_eyes.py: Import eyes on backend startup
  - import_saved_eyes.py: Import from saved directory
- Update docker-compose to mount scripts directory
- Include metadata.json for tracking eye properties
2026-01-25 02:41:37 +00:00
Claude 3fe70fa663 Add public domain eye catalog system for CNC wood carving
Added complete system for populating eye catalog with classical carved eyes:

Features:
- Eye import script (import_eyes.py) for batch/single eye imports
- Public domain source guide (museums: Met, Smithsonian, Getty, etc.)
- Seed catalog system for pre-populating database
- Organized by emotion (serene, fierce, wise, peaceful, etc.)
- Organized by style (Greek, Roman, Egyptian, Renaissance)
- Organized by side (left, right, both)
- Auto-generates thumbnails and metadata
- CNC-ready tagging system

Workflow:
1. Download classical sculpture photos from public domain museums
2. Crop eyes in any image editor
3. Run import script with metadata
4. Eyes saved to catalog with proper tags
5. Apply to colored photos (pure image compositing, no AI regeneration)
6. Convert result to grayscale for CNC carving

Documentation:
- PUBLIC_DOMAIN_EYE_SOURCES.md: Where to find carved eyes
- scripts/README.md: How to import eyes
- Includes recommended starting collection (10 essential eyes)

Benefits for wood carving:
- Build library from master sculptors (2000+ years of proven designs)
- Reusable across all projects
- Consistent emotional weight in carvings
- No AI regeneration - just intelligent copy/paste/blend
- Perfect for CNC workflow (colored preview → grayscale → carve)

The patch library system uses PIL/OpenCV for image compositing,
NOT AI regeneration, so it preserves exact carved geometry.
2026-01-25 02:06:40 +00:00
Claude cfbb9b691f Change backend port to 8101 and simplify Caddy config
- Changed backend port from 8000 to 8101 (avoiding port conflict)
- Added REPLICATE_API_KEY to docker-compose environment variables
- Simplified Caddyfile - only need to reverse proxy frontend
- Frontend nginx internally handles routing API calls to backend
2026-01-24 15:55:49 +00:00