Spaces:
Sleeping
Sleeping
Update faceless_processing.py
Browse files- faceless_processing.py +7 -2
faceless_processing.py
CHANGED
|
@@ -12,7 +12,7 @@ from rembg import remove, new_session
|
|
| 12 |
try:
|
| 13 |
_SESSION_ISNET = new_session("isnet-general-use")
|
| 14 |
except Exception as e:
|
| 15 |
-
print(f"[AI] Failed to load rembg
|
| 16 |
_SESSION_ISNET = None
|
| 17 |
|
| 18 |
# Globally download cascades at startup if missing (runs on main container with internet access)
|
|
@@ -69,6 +69,7 @@ class LineartConfig:
|
|
| 69 |
bilateral_sigma_space: int = 80
|
| 70 |
gaussian_ksize: int = 9
|
| 71 |
min_contour_perimeter: float = 50.0 # filters out short noisy lines
|
|
|
|
| 72 |
|
| 73 |
# Face detection
|
| 74 |
face_scale_factor: float = 1.05
|
|
@@ -207,7 +208,11 @@ def build_interior_edges(rgb: np.ndarray, subject_mask: np.ndarray, cfg: Lineart
|
|
| 207 |
filtered = np.zeros_like(edges)
|
| 208 |
for cnt in contours:
|
| 209 |
if cv2.arcLength(cnt, False) > cfg.min_contour_perimeter:
|
| 210 |
-
cv2.drawContours(filtered, [cnt], -1, 255,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
return filtered
|
| 212 |
|
| 213 |
|
|
|
|
| 12 |
try:
|
| 13 |
_SESSION_ISNET = new_session("isnet-general-use")
|
| 14 |
except Exception as e:
|
| 15 |
+
print(f"[AI] Failed to load rembg session1 {e}")
|
| 16 |
_SESSION_ISNET = None
|
| 17 |
|
| 18 |
# Globally download cascades at startup if missing (runs on main container with internet access)
|
|
|
|
| 69 |
bilateral_sigma_space: int = 80
|
| 70 |
gaussian_ksize: int = 9
|
| 71 |
min_contour_perimeter: float = 50.0 # filters out short noisy lines
|
| 72 |
+
interior_line_thickness: int = 3 # thickness of interior detail lines (>=1)
|
| 73 |
|
| 74 |
# Face detection
|
| 75 |
face_scale_factor: float = 1.05
|
|
|
|
| 208 |
filtered = np.zeros_like(edges)
|
| 209 |
for cnt in contours:
|
| 210 |
if cv2.arcLength(cnt, False) > cfg.min_contour_perimeter:
|
| 211 |
+
cv2.drawContours(filtered, [cnt], -1, 255, cfg.interior_line_thickness)
|
| 212 |
+
|
| 213 |
+
# Mild dilation for uniform, solid strokes
|
| 214 |
+
kernel_dilate = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
|
| 215 |
+
filtered = cv2.dilate(filtered, kernel_dilate, iterations=1)
|
| 216 |
return filtered
|
| 217 |
|
| 218 |
|