feat: initial live.f12.rocks SFTP → gmic/rembg → web pipeline
Event pep stack with SFTPGo inbox, sequential worker, FastAPI gallery/remix, and Traefik-ready compose. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Minimal `rembg` runner, invoked as its own subprocess.
|
||||
|
||||
We deliberately don't shell out to the official `rembg` CLI: that needs
|
||||
the `rembg[cli]` extra (aiohttp, gradio, watchdog, ...) just to run a
|
||||
single background removal. Calling the `remove()` API directly from a
|
||||
tiny script keeps the image smaller while still giving pipeline.py a
|
||||
subprocess boundary to apply `nice` and a hard timeout to.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) != 3:
|
||||
print("usage: python -m app.rembg_cli <input> <output>", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
from rembg import remove
|
||||
|
||||
input_path = Path(sys.argv[1])
|
||||
output_path = Path(sys.argv[2])
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
output_path.write_bytes(remove(input_path.read_bytes()))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user