Tinsae commited on
Commit
f35feb4
1 Parent(s): f5a320e

center crop

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -16,6 +16,15 @@ def create_mask(input):
16
 
17
  input.save(input_path)
18
  bg_removed = remove(input)
 
 
 
 
 
 
 
 
 
19
  bg_removed = bg_removed.resize((512, 512))
20
  bg_removed.save(bg_removed_path)
21
 
 
16
 
17
  input.save(input_path)
18
  bg_removed = remove(input)
19
+
20
+ width, height = bg_removed.size
21
+ new_size = min(width, height)
22
+ left = (width - new_size) // 2
23
+ top = (height - new_size) // 2
24
+ right = (width + new_size) // 2
25
+ bottom = (height + new_size) // 2
26
+ bg_removed = bg_removed.crop((left, top, right, bottom))
27
+
28
  bg_removed = bg_removed.resize((512, 512))
29
  bg_removed.save(bg_removed_path)
30