vitordigitizing commited on
Commit
22c4cfc
Β·
verified Β·
1 Parent(s): eccaf1a

Update faceless_processing.py

Browse files
Files changed (1) hide show
  1. faceless_processing.py +25 -24
faceless_processing.py CHANGED
@@ -84,19 +84,20 @@ class LineartConfig:
84
  min_silhouette_area: float = 200.0
85
 
86
  # Silhouette outline β€” thicker for embroidery visibility
87
- silhouette_line_thickness: int = 4 # bold outer contour
88
-
89
- # Edge detection β€” single pass, balanced for body/clothing details
90
- canny_low: int = 20 # slight lower to recover chin/jaw line
91
- canny_high: int = 130
92
- bilateral_d: int = 5
93
- bilateral_sigma_color: int = 90.0
94
- bilateral_sigma_space: int = 110
95
- gaussian_ksize: int = 11
96
- min_contour_perimeter: float = 40.0
97
- interior_line_thickness: int = 3
98
-
99
- # Secondary detail pass β€” keep OFF
 
100
  enable_detail_pass: bool = False
101
  detail_canny_low: int = 15
102
  detail_canny_high: int = 55
@@ -105,8 +106,8 @@ class LineartConfig:
105
  detail_bilateral_d: int = 7
106
  detail_bilateral_sigma: int = 60
107
 
108
- # Embroidery stitch feasibility
109
- min_embroidery_stitch_px: int = 25
110
 
111
  # Face detection
112
  face_scale_factor: float = 1.05
@@ -123,20 +124,20 @@ class LineartConfig:
123
  # Nose: ~45–60%
124
  # Mouth: ~60–70%
125
  # Chin: ~80–100% ← must NOT be erased
126
- # cy=0.46, ry=0.19 β†’ erases from 27% to 65% β†’ eyebrows above, chin below.
127
  face_cx_ratio: float = 0.50
128
- face_cy_ratio: float = 0.46 # center = eye-to-mouth midpoint
129
- face_rx_ratio: float = 0.27 # moderate width
130
- face_ry_ratio: float = 0.19 # short: 46-19=27% top, 46+19=65% bottom
131
- face_erase_blur: int = 5 # tight blur β†’ won't spill onto eyebrows/chin
132
- face_erase_threshold: int = 90 # lower β†’ harder edge
133
 
134
  # MediaPipe face landmarker: max faces
135
  mediapipe_num_faces: int = 6
136
 
137
  # Eyebrow drawing β€” thick and bold for embroidery visibility
138
- eyebrow_thickness: int = 5 # thick stroke
139
- eyebrow_dilate: int = 2 # extra dilation for bolder lines
140
 
141
 
142
  def _nms_faces(faces: list, iou_thresh: float) -> list:
@@ -330,7 +331,7 @@ def build_interior_edges(rgb: np.ndarray, subject_mask: np.ndarray, cfg: Lineart
330
 
331
  # --- Detail pass (fine features) ---
332
  edges_detail = np.zeros_like(edges_primary)
333
- if getattr(cfg, 'enable_detail_pass', True):
334
  detail_d = getattr(cfg, 'detail_bilateral_d', 7)
335
  detail_sigma = getattr(cfg, 'detail_bilateral_sigma', 60)
336
  detail_ksize = getattr(cfg, 'detail_gaussian_ksize', 5)
 
84
  min_silhouette_area: float = 200.0
85
 
86
  # Silhouette outline β€” thicker for embroidery visibility
87
+ silhouette_line_thickness: int = 6 # bold outer contour
88
+
89
+ # Edge detection β€” aggressive blur + high Canny to skip fabric folds/texture.
90
+ # Only major structural body/clothing borders should survive.
91
+ canny_low: int = 50 # raised: avoids fabric crease noise
92
+ canny_high: int = 170 # raised: only strong structural edges
93
+ bilateral_d: int = 11 # larger diameter β†’ more texture smoothing
94
+ bilateral_sigma_color: int = 130.0 # stronger colour smoothing
95
+ bilateral_sigma_space: int = 130
96
+ gaussian_ksize: int = 17 # bigger kernel β†’ smoother before Canny
97
+ min_contour_perimeter: float = 100.0 # raised: discard short noise/fold lines
98
+ interior_line_thickness: int = 5 # thicker interior lines
99
+
100
+ # Secondary detail pass β€” OFF (adds too much clothing/texture noise)
101
  enable_detail_pass: bool = False
102
  detail_canny_low: int = 15
103
  detail_canny_high: int = 55
 
106
  detail_bilateral_d: int = 7
107
  detail_bilateral_sigma: int = 60
108
 
109
+ # Embroidery stitch feasibility β€” longer minimum so tiny wrinkle lines are dropped
110
+ min_embroidery_stitch_px: int = 70
111
 
112
  # Face detection
113
  face_scale_factor: float = 1.05
 
124
  # Nose: ~45–60%
125
  # Mouth: ~60–70%
126
  # Chin: ~80–100% ← must NOT be erased
127
+ # cy=0.52, ry=0.16 β†’ erases from 36% to 68% β†’ eyebrows safely above, chin safely below.
128
  face_cx_ratio: float = 0.50
129
+ face_cy_ratio: float = 0.52 # center shifted down β†’ protects eyebrow zone
130
+ face_rx_ratio: float = 0.26 # moderate width
131
+ face_ry_ratio: float = 0.16 # tighter: 52-16=36% top, 52+16=68% bottom
132
+ face_erase_blur: int = 3 # tighter blur β†’ won't spill onto eyebrows/chin
133
+ face_erase_threshold: int = 95 # harder edge
134
 
135
  # MediaPipe face landmarker: max faces
136
  mediapipe_num_faces: int = 6
137
 
138
  # Eyebrow drawing β€” thick and bold for embroidery visibility
139
+ eyebrow_thickness: int = 7 # thicker stroke
140
+ eyebrow_dilate: int = 3 # extra dilation for bolder lines
141
 
142
 
143
  def _nms_faces(faces: list, iou_thresh: float) -> list:
 
331
 
332
  # --- Detail pass (fine features) ---
333
  edges_detail = np.zeros_like(edges_primary)
334
+ if getattr(cfg, 'enable_detail_pass', False): # default=False: detail pass adds clothing noise
335
  detail_d = getattr(cfg, 'detail_bilateral_d', 7)
336
  detail_sigma = getattr(cfg, 'detail_bilateral_sigma', 60)
337
  detail_ksize = getattr(cfg, 'detail_gaussian_ksize', 5)