Skip to content

Commit df0c5ea

Browse files
committed
update default weights
1 parent 54f0c14 commit df0c5ea

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

modules/textual_inversion/autocrop.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def crop_image(im, settings):
7171
return results
7272

7373
def focal_point(im, settings):
74-
corner_points = image_corner_points(im, settings)
75-
entropy_points = image_entropy_points(im, settings)
76-
face_points = image_face_points(im, settings)
74+
corner_points = image_corner_points(im, settings) if settings.corner_points_weight > 0 else []
75+
entropy_points = image_entropy_points(im, settings) if settings.entropy_points_weight > 0 else []
76+
face_points = image_face_points(im, settings) if settings.face_points_weight > 0 else []
7777

7878
pois = []
7979

@@ -144,7 +144,7 @@ def image_face_points(im, settings):
144144
settings.dnn_model_path,
145145
"",
146146
(im.width, im.height),
147-
0.8, # score threshold
147+
0.9, # score threshold
148148
0.3, # nms threshold
149149
5000 # keep top k before nms
150150
)
@@ -159,7 +159,7 @@ def image_face_points(im, settings):
159159
results.append(
160160
PointOfInterest(
161161
int(x + (w * 0.5)), # face focus left/right is center
162-
int(y + (h * 0)), # face focus up/down is close to the top of the head
162+
int(y + (h * 0.33)), # face focus up/down is close to the top of the head
163163
size = w,
164164
weight = 1/len(faces[1])
165165
)
@@ -207,7 +207,7 @@ def image_corner_points(im, settings):
207207
np_im,
208208
maxCorners=100,
209209
qualityLevel=0.04,
210-
minDistance=min(grayscale.width, grayscale.height)*0.03,
210+
minDistance=min(grayscale.width, grayscale.height)*0.06,
211211
useHarrisDetector=False,
212212
)
213213

@@ -256,8 +256,8 @@ def image_entropy_points(im, settings):
256256

257257
def image_entropy(im):
258258
# greyscale image entropy
259-
band = np.asarray(im.convert("L"))
260-
# band = np.asarray(im.convert("1"), dtype=np.uint8)
259+
# band = np.asarray(im.convert("L"))
260+
band = np.asarray(im.convert("1"), dtype=np.uint8)
261261
hist, _ = np.histogram(band, bins=range(0, 256))
262262
hist = hist[hist > 0]
263263
return -np.log2(hist / hist.sum()).sum()

modules/ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ def create_ui(wrap_gradio_gpu_call):
12701270

12711271
with gr.Row(visible=False) as process_focal_crop_row:
12721272
process_focal_crop_face_weight = gr.Slider(label='Focal point face weight', value=0.9, minimum=0.0, maximum=1.0, step=0.05)
1273-
process_focal_crop_entropy_weight = gr.Slider(label='Focal point entropy weight', value=0.3, minimum=0.0, maximum=1.0, step=0.05)
1273+
process_focal_crop_entropy_weight = gr.Slider(label='Focal point entropy weight', value=0.15, minimum=0.0, maximum=1.0, step=0.05)
12741274
process_focal_crop_edges_weight = gr.Slider(label='Focal point edges weight', value=0.5, minimum=0.0, maximum=1.0, step=0.05)
12751275
process_focal_crop_debug = gr.Checkbox(label='Create debug image')
12761276

0 commit comments

Comments
 (0)