@@ -67,7 +67,7 @@ def process(self, bind: BMABBind, steps, cfg_scale, sampler_name, scheduler, den
6767 if bind .context is not None :
6868 steps , cfg_scale , sampler_name , scheduler = bind .context .update (steps , cfg_scale , sampler_name , scheduler )
6969
70- boxes , confs = predict (image , 'person_yolov8m -seg.pt' , 0.35 )
70+ boxes , confs = predict (image , 'person_yolov8n -seg.pt' , 0.35 )
7171 if len (boxes ) == 0 :
7272 results .append (image .convert ('RGB' ))
7373 continue
@@ -93,7 +93,7 @@ def process(self, bind: BMABBind, steps, cfg_scale, sampler_name, scheduler, den
9393 if method == 'stretching' :
9494 results .append (stretching_image .convert ('RGB' ))
9595 elif method == 'inpaint' :
96- mask , box = utils .get_mask_with_alignment (image , alignment , int (image .width * image_ratio ), int (image .height * image_ratio ), dilation )
96+ mask , box = utils .get_mask_with_alignment (image , alignment , int (image .width * image_ratio ), int (image .height * image_ratio ))
9797 blur = ImageFilter .GaussianBlur (10 )
9898 blur_mask = mask .filter (blur )
9999 blur_mask = ImageOps .invert (blur_mask )
@@ -112,13 +112,13 @@ def process(self, bind: BMABBind, steps, cfg_scale, sampler_name, scheduler, den
112112 'height' : stretching_image .height ,
113113 }
114114 image = process .process_img2img_with_mask (bind , stretching_image , img2img , mask )
115- stretching_image .save ('stretching_image.png' )
116- mask .save ('mask.png' )
117115 results .append (image .convert ('RGB' ))
118116 elif method == 'inpaint+lama' :
119- mask , box = utils .get_mask_with_alignment (image , alignment , int (image .width * image_ratio ), int (image .height * image_ratio ), dilation )
117+ mask , box = utils .get_mask_with_alignment (image , alignment , int (image .width * image_ratio ), int (image .height * image_ratio ))
120118 lama = LamaInpainting ()
121119 stretching_image = lama (stretching_image , mask )
120+ stretching_image .save ('stretching_image.png' )
121+ mask .save ('mask.png' )
122122 img2img = {
123123 'steps' : steps ,
124124 'cfg_scale' : cfg_scale ,
@@ -162,3 +162,31 @@ def process(self, image, width, height, fill_black):
162162 results .append (utils .resize_and_fill (img , width , height , fill_black = fill_black ))
163163 pixels = utils .get_pixels_from_pils (results )
164164 return (pixels ,)
165+
166+
167+ class BMABCrop :
168+ @classmethod
169+ def INPUT_TYPES (s ):
170+ return {
171+ 'required' : {
172+ 'image' : ('IMAGE' ,),
173+ 'width' : ('INT' , {'default' : 2 , 'min' : 0 , 'max' : 10000 }),
174+ 'height' : ('INT' , {'default' : 3 , 'min' : 0 , 'max' : 10000 }),
175+ 'resize' : (('disable' , 'enable' ), )
176+ },
177+ }
178+
179+ RETURN_TYPES = ('IMAGE' , )
180+ RETURN_NAMES = ('image' , )
181+ FUNCTION = 'process'
182+
183+ CATEGORY = 'BMAB/resize'
184+
185+ def process (self , image , width , height , resize ):
186+ results = []
187+ resize = resize == 'enable'
188+ for img in utils .get_pils_from_pixels (image ):
189+ results .append (utils .crop (img , width , height , resized = resize ))
190+ pixels = utils .get_pixels_from_pils (results )
191+ return (pixels ,)
192+
0 commit comments