HideMyData / pipeline /preprocess.py
Migueldiaz1
Hide My Data — Gradio app + pipeline + pesos
e0adda0
Raw
History Blame Contribute Delete
641 Bytes
import cv2
import numpy as np
def clahe_canny(bgr: np.ndarray) -> np.ndarray:
"""Return 3-channel image. Must match the preprocessing used to train the
weights currently loaded by the detector."""
gray = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY)
enhanced = cv2.createCLAHE(clipLimit=6.0, tileGridSize=(16, 16)).apply(gray)
return cv2.merge([enhanced, enhanced, enhanced]) # [C, C, C] — matches `clahe_best_yolox`
def to_gray_3ch(bgr: np.ndarray) -> np.ndarray:
"""Grayscale replicated to 3 channels (baseline pipeline input)."""
g = cv2.cvtColor(bgr, cv2.COLOR_BGR2GRAY)
return cv2.merge([g, g, g])