mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: kill all silent fallbacks — fail clearly, never degrade silently
Remove 9 silent fallback chains in the Python sidecar: - upscale: RealESRGAN→Lanczos (now errors with install guidance) - upscale: GFPGAN skip (now errors with install guidance) - gpu: GPU→CPU (now reports device in response, never silent) - remove_bg: alpha matting fallback (now errors with retry guidance) - remove_bg: GPU→CPU session (now reports device) - colorize: DDColor→OpenCV (now errors with install guidance) - enhance_faces: CodeFormer→GFPGAN (now errors with install guidance) - ocr: quality cascade (now errors at requested level) - bridge: dispatcher crash retry (now reports retry in stderr) Also: raise red_eye max_faces 10→50, face_landmarks max_num_faces configurable, restore.py min face size 48→24px.
This commit is contained in:
@@ -155,7 +155,7 @@ def inpaint_damage(img_bgr, mask):
|
||||
from gpu import safe_onnx_session
|
||||
|
||||
model_path = _get_lama_path()
|
||||
session = safe_onnx_session(model_path)
|
||||
session, _device = safe_onnx_session(model_path)
|
||||
|
||||
orig_h, orig_w = img_bgr.shape[:2]
|
||||
img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
|
||||
@@ -317,7 +317,7 @@ def enhance_faces(img_bgr, fidelity=0.7):
|
||||
|
||||
# Load CodeFormer model
|
||||
model_path = _get_codeformer_path()
|
||||
session = safe_onnx_session(model_path)
|
||||
session, _device = safe_onnx_session(model_path)
|
||||
input_names = [inp.name for inp in session.get_inputs()]
|
||||
|
||||
result = img_bgr.copy()
|
||||
@@ -329,8 +329,7 @@ def enhance_faces(img_bgr, fidelity=0.7):
|
||||
w = face_box["w"]
|
||||
h = face_box["h"]
|
||||
|
||||
# Skip very small faces (under 48px) - enhancement won't help
|
||||
if w < 48 or h < 48:
|
||||
if w < 24 or h < 24:
|
||||
continue
|
||||
|
||||
# Expand bounding box by ~80% for hair, forehead, chin
|
||||
@@ -473,7 +472,7 @@ def colorize_bw(img_bgr, intensity=0.85):
|
||||
if not os.path.exists(DDCOLOR_MODEL_PATH):
|
||||
return img_bgr, False
|
||||
|
||||
session = safe_onnx_session(DDCOLOR_MODEL_PATH)
|
||||
session, _device = safe_onnx_session(DDCOLOR_MODEL_PATH)
|
||||
input_name = session.get_inputs()[0].name
|
||||
input_shape = session.get_inputs()[0].shape
|
||||
model_size = (
|
||||
@@ -545,6 +544,9 @@ def main():
|
||||
scratch_sensitivity = "medium"
|
||||
|
||||
try:
|
||||
from gpu import gpu_available
|
||||
device = "cuda" if gpu_available() else "cpu"
|
||||
|
||||
emit_progress(5, "Opening image")
|
||||
img_bgr = cv2.imread(input_path, cv2.IMREAD_COLOR)
|
||||
if img_bgr is None:
|
||||
@@ -633,6 +635,7 @@ def main():
|
||||
"facesEnhanced": faces_found,
|
||||
"isGrayscale": bw_detected,
|
||||
"colorized": colorized,
|
||||
"device": device,
|
||||
"output_path": output_path,
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user