Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
*.pth binary
*.ckpt binary
*.safetensors binary

# Preserve pinned vendor bytes, including upstream license formatting.
ui/vendor/** -text -whitespace
29 changes: 26 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Check Python correctness
run: python -m ruff check .
- name: Compile application and tests without importing models
run: python -m compileall -q remwm.py remwmgui.py utils.py lama_inpaint tests
run: python -m compileall -q remwm.py remwmgui.py desktop_main.py desktop_runtime.py desktop_models.py model_assets.py utils.py lama_inpaint scripts tests
- name: Run CPU tests
run: python -m pytest
- name: Check Bash syntax
Expand Down Expand Up @@ -99,7 +99,30 @@ jobs:
sudo apt-get install -y libegl1 libgl1 libxkbcommon-x11-0 libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0 libxcb-xinerama0 libxcb-randr0 libnss3 libasound2t64
- name: Check installed desktop backend (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a python scripts/check_webview.py
run: xvfb-run -a python scripts/check_desktop.py
- name: Check installed desktop backend (Windows/macOS)
if: runner.os != 'Linux'
run: python scripts/check_webview.py
run: python scripts/check_desktop.py

windows-portable:
name: Windows portable executable
runs-on: windows-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Build independent embedded runtime and executable
run: python scripts/build_windows.py --output "${{ runner.temp }}/portable" --cache "${{ runner.temp }}/downloads" --backend cpu --skip-archive
- name: Exercise the executable and real offline desktop page
shell: pwsh
run: |
$version = (Get-Content VERSION -Raw).Trim()
$bundle = Join-Path '${{ runner.temp }}/portable' "WatermarkRemover-AI-$version-windows-x64-cpu"
$process = Start-Process -FilePath (Join-Path $bundle 'WatermarkRemover-AI.exe') -ArgumentList '--check' -WindowStyle Hidden -PassThru
$handle = $process.Handle
if (-not $process.WaitForExit(120000)) { $process.Kill(); throw 'Portable check timed out' }
if ($process.ExitCode -ne 0) { throw "Portable check failed: $($process.ExitCode)" }
55 changes: 55 additions & 0 deletions .github/workflows/windows-portable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Windows portable packages

on:
workflow_dispatch:
push:
tags: ["v*"]

permissions:
contents: read

jobs:
build:
name: Portable (${{ matrix.backend }})
runs-on: windows-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
backend: [cpu, cu126]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Validate release tag
shell: pwsh
run: |
$version = (Get-Content VERSION -Raw).Trim()
if ($env:GITHUB_REF_TYPE -eq 'tag' -and $env:GITHUB_REF_NAME -ne "v$version") { throw 'Tag must match VERSION' }
- name: Build folder and archive
run: python scripts/build_windows.py --output dist --cache "${{ runner.temp }}/downloads" --backend ${{ matrix.backend }}
- name: Verify executable and local GUI
shell: pwsh
run: |
$version = (Get-Content VERSION -Raw).Trim()
$name = "WatermarkRemover-AI-$version-windows-x64-${{ matrix.backend }}"
$destination = Join-Path $env:RUNNER_TEMP 'extracted portable'
python -m zipfile -e "dist/$name.zip" "$destination"
if ($LASTEXITCODE -ne 0) { throw 'Archive extraction failed' }
$bundle = Join-Path $destination $name
$process = Start-Process -FilePath (Join-Path $bundle 'WatermarkRemover-AI.exe') -ArgumentList '--check' -WindowStyle Hidden -PassThru
$handle = $process.Handle
if (-not $process.WaitForExit(120000)) { $process.Kill(); throw 'Portable check timed out' }
if ($process.ExitCode -ne 0) { throw "Portable check failed: $($process.ExitCode)" }
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: windows-${{ matrix.backend }}
path: |
dist/*.zip
dist/*.sha256
compression-level: 0
if-no-files-found: error
retention-days: 14
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ huggingface/
.venv-test/
.pytest_cache/
.ruff_cache/

node_modules/
build-downloads/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CI runs these checks on Windows, Linux, and macOS. It also parses the PowerShell

These lightweight checks use CPU fixtures. They do not install the full application, launch its GUI, download model weights, or prove CUDA/MPS compatibility. The test dependencies are separate from the application dependencies. A successful `pip check` in the test environment only validates that environment.

A separate application CI job installs `requirements.txt` on all three platforms with the normal resolver, runs `pip check` in that environment, verifies application imports and CLI help, and tests the adapter using a generated TorchScript fixture. It also checks image and short-video routing without downloading detection models. This job does not prove a GUI interaction or real-model/GPU inference. See [LaMA runtime validation](docs/lama-runtime.md#validation).
A separate application CI job installs `requirements.txt` on all three platforms with the normal resolver, runs `pip check` in that environment, verifies application imports and CLI help, and tests the adapter using a generated TorchScript fixture. It also checks image and short-video routing without downloading detection models. This job also opens the real local desktop page and exercises its JavaScript/Python bridge. It does not prove real-model/GPU inference. See [LaMA runtime validation](docs/lama-runtime.md#validation).

## Evidence required by change type

Expand All @@ -47,7 +47,7 @@ GPU/model integration tests require a separate trusted environment and must not

Automated review provides suggestions; maintainers verify findings against the code and test evidence. A bot's approval does not replace application testing. Resolve applicable review findings or explain why they do not apply. Maintainers decide when to merge.

Once the new CI jobs have passed reliably, maintainers can require their status checks through repository rules. Adding this workflow alone does not enable branch protection. Full-manifest installation checks run in the application job; installer-script execution and GUI interaction still require separate validation on affected platforms.
Once the new CI jobs have passed reliably, maintainers can require their status checks through repository rules. Adding this workflow alone does not enable branch protection. Full-manifest installation checks run in the application job; installer-script execution and GUI interactions beyond the automated desktop check still require separate validation on affected platforms.

## Dependency updates

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ https://github.com/user-attachments/assets/505be2a8-8eda-4def-90b6-5a4ceefee456

---

## Windows portable release

The versioned Windows package includes an `.exe` launcher, Python and the desktop
runtime. See [portable setup, model downloads and troubleshooting](docs/windows-portable.md).
The first launch prepares verified models with visible progress and a retry button.

## Installation

### Windows
Expand Down
19 changes: 19 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,22 @@ asset digest. The runtime uses the pinned SHA-256, not MD5 or an environment
variable supplied checksum. This is an integrity pin, not an upstream signature.
For model provenance and terms, see [LaMA](https://github.com/advimman/lama)
and the artifact publisher. Code licensing does not replace model/data terms.

## Offline desktop assets

- Alpine.js 3.13.3: MIT, https://github.com/alpinejs/alpine/tree/v3.13.3 ; license in `ui/vendor/ALPINE-LICENSE.md`.
- Tailwind CSS 3.4.17: MIT, https://github.com/tailwindlabs/tailwindcss/tree/v3.4.17 ; generated CSS and license in `ui/vendor`. Rebuild with `npm ci --ignore-scripts` and `npm run build:ui`.
- Space Mono, Rubik Glitch, Inter, Cinzel, Dancing Script, Oswald, Playfair Display and Mali: SIL Open Font License 1.1. Font files were obtained from Google Fonts; the corresponding OFL files are included in `ui/vendor`. See https://github.com/google/fonts .
- `ui/vendor/manifest.json` records the bundled asset SHA-256 digests.

The Windows portable package includes CPython under the PSF license and PySide6/Qt
under their distributed licenses, including LGPL components. Their license files
remain in the Python distribution and installed package metadata. Libraries remain
as separate replaceable files. See https://doc.qt.io/qtforpython-6/licenses.html
for licensing and corresponding source references. The package also preserves
PyTorch and other dependencies' license files in their installed distributions.

Florence-2 assets are pinned to revision `4271c66b88cdbc05735372ec13b2360108de5317`
of `florence-community/Florence-2-large`. `models/florence.json` records sizes and
SHA-256 digests checked against the repository's Git/LFS metadata. Model files are
downloaded separately, with byte verification before use.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.68.0
8 changes: 8 additions & 0 deletions desktop_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Windowed entry point for source installs and the portable executable."""
from desktop_runtime import configure_runtime

configure_runtime()

if __name__ == "__main__":
from remwmgui import main
main()
83 changes: 83 additions & 0 deletions desktop_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""Keep model verification/downloads off the desktop bridge and UI threads."""

import json
import subprocess
import threading

from desktop_runtime import APP_ROOT, python_executable, worker_options


class ModelPreparation:
"""One preparation worker per window, with pollable progress and explicit retry."""

def __init__(self):
"""Start idle; callers decide when to check or download model assets."""
self._lock = threading.Lock()
self._process = None
self._running = False
self._closed = False
self._state = dict(status="unchecked", message="Checking model files...")

def status(self):
"""Return a copy so bridge serialization never races with worker updates."""
with self._lock:
return dict(self._state, busy=self._running)

def start(self, *, check=False):
"""Start checking or downloading; completed/failed jobs can be retried."""
with self._lock:
if self._closed:
return {"error": "Window is closing"}
if self._running:
return {"error": "Model preparation is already running"}
self._running = True
self._state = dict(status="checking", message="Checking model files...")
threading.Thread(target=self._run, args=(check,), daemon=True).start()
return {"status": "started"}

def _run(self, check):
"""Consume structured progress while keeping errors visible and retryable."""
try:
cmd = [python_executable(), str(APP_ROOT / "model_assets.py")]
if check:
cmd.append("--check")
with self._lock:
if self._closed:
return
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
**worker_options())
self._process = process
for line in process.stdout:
try:
event = json.loads(line)
except ValueError:
continue
if isinstance(event, dict) and "status" in event:
with self._lock:
self._state = event
process.stdout.close()
code = process.wait()
with self._lock:
if code or self._state.get("status") != "ready":
if self._state.get("status") not in {"missing", "error"}:
self._state = dict(status="error", message=f"Model preparation stopped (exit {code}). Please retry.")
except Exception as exc:
with self._lock:
self._state = dict(status="error", message=str(exc))
finally:
with self._lock:
self._process = None
self._running = False

def close(self):
"""Terminate only this window's worker; downloads remain safe to retry."""
with self._lock:
self._closed = True
process = self._process
if process and process.poll() is None:
process.terminate()
try:
process.wait(timeout=3)
except subprocess.TimeoutExpired:
process.kill()
process.wait(timeout=3)
53 changes: 53 additions & 0 deletions desktop_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Paths and subprocess settings shared by source and portable desktop launches."""

import logging
import os
from pathlib import Path
import subprocess
import sys

APP_ROOT = Path(__file__).resolve().parent


def data_dir():
"""Keep writable user state outside application files, or beside a portable build."""
override = os.environ.get("WMR_DATA_DIR")
if override:
return Path(override).expanduser().resolve()
if (APP_ROOT / "portable.flag").exists():
return APP_ROOT / "data"
if sys.platform == "win32":
return Path(os.environ.get("LOCALAPPDATA", str(Path.home()))) / "WatermarkRemover-AI"
return Path(os.environ.get("XDG_DATA_HOME", str(Path.home() / ".local/share"))) / "WatermarkRemover-AI"


def configure_runtime():
"""Prepare logs and portable caches before importing the graphical backend."""
root = data_dir()
root.mkdir(parents=True, exist_ok=True)
if (APP_ROOT / "portable.flag").exists():
os.environ.setdefault("TORCH_HOME", str(root / "models/torch"))
os.environ.setdefault("HF_HOME", str(root / "models/huggingface"))
for name in ("stdout", "stderr"):
if getattr(sys, name) is None:
setattr(sys, name, (root / "desktop.log").open("a", encoding="utf-8", buffering=1))
logging.basicConfig(filename=root / "desktop.log", level=logging.INFO,
format="%(asctime)s %(levelname)s %(message)s", encoding="utf-8")


def python_executable():
"""Workers need python.exe with real pipes even when the GUI uses pythonw.exe."""
executable = Path(sys.executable)
if executable.name.lower() == "pythonw.exe":
return str(executable.with_name("python.exe"))
return str(executable)


def worker_options(*, offline=False):
"""Launch bounded local workers without console windows or shell interpretation."""
env = os.environ.copy()
env.update(PYTHONUNBUFFERED="1", PYTHONIOENCODING="utf-8")
if offline:
env.update(HF_HUB_OFFLINE="1", TRANSFORMERS_OFFLINE="1")
return dict(cwd=str(APP_ROOT), env=env, text=True, encoding="utf-8", errors="replace",
creationflags=subprocess.CREATE_NO_WINDOW if sys.platform == "win32" else 0)
Loading