refactor: share env-bool parsing and logging setup
env_utils.env_bool replaces duplicated truthy parsing in config and rembg_cli. logging_config.configure_logging unifies entry-point setup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+5
-1
@@ -9,6 +9,8 @@ from __future__ import annotations
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from .env_utils import env_bool
|
||||
|
||||
|
||||
def _int_env(name: str, default: int) -> int:
|
||||
try:
|
||||
@@ -55,13 +57,15 @@ MAX_FILTER_ATTEMPTS = _int_env("MAX_FILTER_ATTEMPTS", 8)
|
||||
# Longest edge after preprocess (ImageMagick). Keeps rembg/gmic sane on
|
||||
# large camera JPEGs.
|
||||
MAX_EDGE_PX = _int_env("MAX_EDGE_PX", 2000)
|
||||
# ImageMagick preprocess step timeout (resize + orient).
|
||||
PREPROCESS_TIMEOUT = _int_env("PREPROCESS_TIMEOUT", 120)
|
||||
# Generous on purpose: the very first rembg call also downloads the model,
|
||||
# which can take a while depending on the link.
|
||||
REMBG_TIMEOUT = _int_env("REMBG_TIMEOUT", 600)
|
||||
# birefnet-general OOMs on the ~8GB event box; u2net + alpha matting fits
|
||||
# and is the practical equivalent of `rembg i -a`.
|
||||
REMBG_MODEL = os.environ.get("REMBG_MODEL", "u2net")
|
||||
REMBG_ALPHA = os.environ.get("REMBG_ALPHA", "1").strip().lower() in {"1", "true", "yes", "on"}
|
||||
REMBG_ALPHA = env_bool("REMBG_ALPHA", True)
|
||||
NICE_LEVEL = _int_env("NICE_LEVEL", 18)
|
||||
|
||||
# gmic CLI binary, override for local dev if not on PATH. rembg has no
|
||||
|
||||
Reference in New Issue
Block a user