13
13
import modules .deepbooru as deepbooru
14
14
15
15
16
- def preprocess (process_src , process_dst , process_width , process_height , preprocess_txt_action , process_flip , process_split , process_caption , process_caption_deepbooru = False , split_threshold = 0.5 , overlap_ratio = 0.2 , process_entropy_focus = False ):
16
+ def preprocess (process_src , process_dst , process_width , process_height , preprocess_txt_action , process_flip , process_split , process_caption , process_caption_deepbooru = False , split_threshold = 0.5 , overlap_ratio = 0.2 , process_focal_crop = False , process_focal_crop_face_weight = 0.9 , process_focal_crop_entropy_weight = 0.3 , process_focal_crop_edges_weight = 0.5 , process_focal_crop_debug = False ):
17
17
try :
18
18
if process_caption :
19
19
shared .interrogator .load ()
@@ -23,7 +23,7 @@ def preprocess(process_src, process_dst, process_width, process_height, preproce
23
23
db_opts [deepbooru .OPT_INCLUDE_RANKS ] = False
24
24
deepbooru .create_deepbooru_process (opts .interrogate_deepbooru_score_threshold , db_opts )
25
25
26
- preprocess_work (process_src , process_dst , process_width , process_height , preprocess_txt_action , process_flip , process_split , process_caption , process_caption_deepbooru , split_threshold , overlap_ratio , process_entropy_focus )
26
+ preprocess_work (process_src , process_dst , process_width , process_height , preprocess_txt_action , process_flip , process_split , process_caption , process_caption_deepbooru , split_threshold , overlap_ratio , process_focal_crop , process_focal_crop_face_weight , process_focal_crop_entropy_weight , process_focal_crop_edges_weight , process_focal_crop_debug )
27
27
28
28
finally :
29
29
@@ -35,7 +35,7 @@ def preprocess(process_src, process_dst, process_width, process_height, preproce
35
35
36
36
37
37
38
- def preprocess_work (process_src , process_dst , process_width , process_height , preprocess_txt_action , process_flip , process_split , process_caption , process_caption_deepbooru = False , split_threshold = 0.5 , overlap_ratio = 0.2 , process_entropy_focus = False ):
38
+ def preprocess_work (process_src , process_dst , process_width , process_height , preprocess_txt_action , process_flip , process_split , process_caption , process_caption_deepbooru = False , split_threshold = 0.5 , overlap_ratio = 0.2 , process_focal_crop = False , process_focal_crop_face_weight = 0.9 , process_focal_crop_entropy_weight = 0.3 , process_focal_crop_edges_weight = 0.5 , process_focal_crop_debug = False ):
39
39
width = process_width
40
40
height = process_height
41
41
src = os .path .abspath (process_src )
@@ -139,27 +139,27 @@ def split_pic(image, inverse_xy):
139
139
ratio = (img .height * width ) / (img .width * height )
140
140
inverse_xy = True
141
141
142
- processing_option_ran = False
142
+ process_default_resize = True
143
143
144
144
if process_split and ratio < 1.0 and ratio <= split_threshold :
145
145
for splitted in split_pic (img , inverse_xy ):
146
146
save_pic (splitted , index , existing_caption = existing_caption )
147
- processing_option_ran = True
147
+ process_default_resize = False
148
148
149
149
if process_entropy_focus and img .height != img .width :
150
150
autocrop_settings = autocrop .Settings (
151
151
crop_width = width ,
152
152
crop_height = height ,
153
- face_points_weight = 0.9 ,
154
- entropy_points_weight = 0.7 ,
155
- corner_points_weight = 0.5 ,
156
- annotate_image = False
153
+ face_points_weight = process_focal_crop_face_weight ,
154
+ entropy_points_weight = process_focal_crop_entropy_weight ,
155
+ corner_points_weight = process_focal_crop_edges_weight ,
156
+ annotate_image = process_focal_crop_debug
157
157
)
158
- focal = autocrop .crop_image (img , autocrop_settings )
159
- save_pic (focal , index , existing_caption = existing_caption )
160
- processing_option_ran = True
158
+ for focal in autocrop .crop_image (img , autocrop_settings ):
159
+ save_pic (focal , index , existing_caption = existing_caption )
160
+ process_default_resize = False
161
161
162
- if not processing_option_ran :
162
+ if process_default_resize :
163
163
img = images .resize_image (1 , img , width , height )
164
164
save_pic (img , index , existing_caption = existing_caption )
165
165
0 commit comments