modelbeast/server/operators/mflux_image_edit/run.py
MODELBEAST f0bac67edb Local mflux operators: seedvr2_upscale + mflux_image_edit (free, ungated)
Two new local image-prep operators through the already-installed mflux 0.18 (no
new heavy install, ungated weights):
- seedvr2_upscale: mflux-upscale-seedvr2 (ByteDance SeedVR2, MIT) — faithful
  local upscale, free alternative to cloud fal_upscale
- mflux_image_edit: mflux-generate-qwen-edit (Qwen-Image-Edit, Apache-2.0) —
  local prompt-based image editing, free alternative to fal_image_edit

Research verdict on dinov3 (recorded): waiting for Meta approval is the only
legitimate path — TRELLIS.2's DiT is trained on DINOv3 ViT-L/16 features so the
encoder can't be swapped, and the only ungated mirrors are unauthorized
re-uploads. trellis_mac stays blocked on the pending gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 01:37:56 +10:00

49 lines
1.5 KiB
Python

import argparse
import json
import subprocess
import sys
from pathlib import Path
ap = argparse.ArgumentParser()
ap.add_argument("--input", action="append", default=[])
ap.add_argument("--outdir", required=True)
ap.add_argument("--params", default="{}")
a = ap.parse_args()
p = json.loads(a.params)
if not a.input:
print("ERROR: no input image")
sys.exit(1)
if not p.get("prompt"):
print("ERROR: prompt is required — describe the edit you want")
sys.exit(1)
cli = Path(sys.executable).parent / "mflux-generate-qwen-edit"
if not cli.exists():
print(f"ERROR: {cli} missing. Run scripts/install_mflux.sh")
sys.exit(1)
src = Path(a.input[0])
outdir = Path(a.outdir)
out = outdir / f"{src.stem}_edited.png"
cmd = [str(cli), "--image-paths", str(src.resolve()),
"--prompt", p["prompt"],
"--steps", str(p.get("steps", 25)),
"--seed", str(p.get("seed", 42)),
"--guidance", str(p.get("guidance", 4.0)),
"--output", str(out.resolve())]
print("+", " ".join(cmd), flush=True)
print("(first run downloads Qwen-Image-Edit weights)", flush=True)
res = subprocess.run(cmd, cwd=str(outdir), stdout=sys.stdout, stderr=subprocess.STDOUT)
if res.returncode != 0:
sys.exit(res.returncode)
pngs = sorted(outdir.rglob("*.png"))
if not pngs:
print("ERROR: no edited image produced")
sys.exit(1)
img = out if out.exists() else pngs[-1]
(outdir / "result.json").write_text(json.dumps(
{"outputs": [{"path": img.name, "meta": {"tool": "qwen-image-edit"}}]}))
print(f"done: {img.name}", flush=True)