Skip to main content

Shared Gradio and CLI runtime for MatAnyone and MatAnyone 2 on Windows.

Project description

MatAnyone hero banner

MatAnyone

Windows-friendly local runtime for MatAnyone and MatAnyone 2, with a shared core that powers both the Gradio WebUI and a reproducible CLI.

日本語 | Docs | MatAnyone 2 | MatAnyone | Original Space

Repo Checks Docs Pages Release Package

What This Repo Provides

  • A shared runtime core in matanyone2/demo_core.py used by both the CLI and the Gradio app
  • A package entrypoint, matanyone2-runtime, with cli and webui subcommands
  • Timestamped run folders under results/<input-name>_<timestamp>/
  • Debug artifacts for every run, including SAM previews, masks, frame snapshots, and metadata.json
  • Windows-friendly setup with uv, automatic checkpoint downloads, and ffmpeg discovery

Quick Start

Requirements:

  • Windows 10 or Windows 11
  • Python 3.10
  • uv
  • git
  • ffmpeg
  • NVIDIA GPU recommended for practical speed

Install the base tools with winget:

winget install astral-sh.uv
winget install Git.Git
winget install Gyan.FFmpeg

Create the environment and install the package:

uv venv --python 3.10
uv pip install --python .\.venv\Scripts\python.exe --upgrade pip setuptools wheel
uv pip install --python .\.venv\Scripts\python.exe torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
uv pip install --python .\.venv\Scripts\python.exe -e .

Installed entrypoints:

  • matanyone2-runtime
  • matanyone-cli
  • matanyone-gradio
  • python -m matanyone2

Recommended unified entrypoint:

  • matanyone2-runtime webui ...
  • matanyone2-runtime cli ...

Launch the WebUI:

uv run --python .\.venv\Scripts\python.exe matanyone2-runtime webui --device cuda --port 7860 --server_name 127.0.0.1

Run the shared CLI:

uv run --python .\.venv\Scripts\python.exe matanyone2-runtime cli --input .\media\bookcat.mp4 --device cpu --performance_profile fast --cpu_threads 8 --positive_point 280,180 --output_dir .\results

Then open http://127.0.0.1:7860 for the WebUI, or inspect the generated run folder for CLI outputs.

Run Output Layout

Every run creates a dedicated directory such as results/bookcat_1773163828_6577592/.

Typical contents:

  • final outputs such as *_foreground.mp4, *_alpha.mp4, *_mask.png, and *_sam_preview.png
  • debug artifacts such as input_first_frame.png, input_selected_frame.png, sam_selected_preview.png, and sam_selected_mask.png
  • first and last matting snapshots such as matting_output_first_* and matting_output_last_*
  • metadata.json with the exact runtime configuration

This makes it easier to compare runs, reproduce experiments, and inspect intermediate state without launching the UI.

CLI and WebUI Share The Same Core

The Gradio app and the CLI both run through matanyone2/demo_core.py. Shared responsibilities include:

  • runtime configuration and ffmpeg setup
  • image and video loading
  • SAM prompt handling
  • matting orchestration
  • final output writing
  • debug artifact export

Thin entrypoints:

  • hugging_face/app.py for the WebUI
  • matanyone2/cli.py for direct CLI execution
  • matanyone2/runtime.py for the package-friendly matanyone2-runtime launcher
  • scripts/run_pipeline_check.py as a compatibility wrapper around the CLI

Reproducible Validation

To reproduce the historical bookcat-profile-exp style run more closely, pin the same prompt points and FPS settings:

uv run --python .\.venv\Scripts\python.exe matanyone2-runtime cli --input .\media\bookcat.mp4 --device cpu --performance_profile fast --cpu_threads 8 --sam_model_type vit_h --frame_limit 241 --video_target_fps 0 --output_fps 12 --positive_point 280,180 --negative_point 30,30 --negative_point 530,30 --model "MatAnyone 2" --output_dir .\results

This workflow is also useful for CI smoke checks, scripted regression checks, and local benchmarking.

CI/CD

GitHub Actions now covers the main repository lifecycle:

  • Repo Checks: builds docs, compiles maintained Python sources, lints the maintained runtime files, builds the package, and verifies the packaged entrypoints
  • Docs Pages: builds the VitePress site and deploys it to GitHub Pages on pushes to main
  • Release Package: builds wheel and sdist artifacts on v* tags, attaches them to a GitHub Release with SHA256 checksums, and publishes them to PyPI

If you want to cut a release:

git tag v0.1.0
git push origin v0.1.0

That tag will trigger the package release workflow automatically.

To make PyPI publishing work, configure a trusted publisher for this repository on PyPI and bind it to the pypi GitHub Actions environment.

Documentation

Full docs live at sunwood-ai-labs.github.io/MatAnyone2-Gradio-Windows and in docs/.

To preview the docs site locally:

cd docs
npm install
npm run docs:dev

Repository Layout

Path Purpose
hugging_face/app.py Gradio app entrypoint and UI wiring
hugging_face/tools/ UI helper utilities used by the demo
matanyone2/demo_core.py Shared runtime for WebUI and CLI
matanyone2/cli.py Direct CLI entrypoint
matanyone2/runtime.py Unified package entrypoint with cli and webui subcommands
matanyone2/ Upstream model and inference implementation
pretrained_models/ Auto-downloaded checkpoints, ignored by git
results/ Generated outputs and debug artifacts, ignored by git
media/ Repository branding and documentation assets

Troubleshooting

  • If ffmpeg is not detected, confirm ffmpeg.exe is on PATH or installed via winget
  • If CUDA startup fails, install a matching PyTorch build for your driver or switch to --device cpu
  • If the first launch takes a while, checkpoints and sample media are being downloaded on demand
  • If you want different host or port settings, use --server_name and --port

Attribution And License

This repository is a derivative adaptation of:

The included LICENSE is the upstream S-Lab License 1.0. Commercial use still requires permission from the original authors listed in that license file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matanyone2_runtime-0.1.0.tar.gz (70.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matanyone2_runtime-0.1.0-py3-none-any.whl (83.4 kB view details)

Uploaded Python 3

File details

Details for the file matanyone2_runtime-0.1.0.tar.gz.

File metadata

  • Download URL: matanyone2_runtime-0.1.0.tar.gz
  • Upload date:
  • Size: 70.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for matanyone2_runtime-0.1.0.tar.gz
Algorithm Hash digest
SHA256 29cec82f0fb2e3c7e70645f4687094191c14a189133977c6b836bdf7fb0f367e
MD5 9d5a89f59b5428e89cea75dfdb862e83
BLAKE2b-256 92e1aa612f0735a892ca9a83ac04087a26f44cb5083406ed6cbd5241a581ba69

See more details on using hashes here.

Provenance

The following attestation bundles were made for matanyone2_runtime-0.1.0.tar.gz:

Publisher: release-package.yml on Sunwood-ai-labs/MatAnyone2-Gradio-Windows

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matanyone2_runtime-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for matanyone2_runtime-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51ef46598714f1174dbade04f11dd79be91fa2b4b3e839a54cf3fcf487142b26
MD5 e24f939c88855c43c689ed8ab90447eb
BLAKE2b-256 edb002b5e342816baac244147a3412407e7534438d9ce85a437ac57e0b6552fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for matanyone2_runtime-0.1.0-py3-none-any.whl:

Publisher: release-package.yml on Sunwood-ai-labs/MatAnyone2-Gradio-Windows

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page