Spaces:
Runtime error
Runtime error
Upload crop.py
Browse files
crop.py
CHANGED
@@ -3,7 +3,8 @@ from pathlib import Path
|
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
|
6 |
-
def crop(
|
|
|
7 |
img_width, img_height = img.size
|
8 |
tgt_width, tgt_height = size
|
9 |
point = (point[0]*img_width, point[1]*img_height)
|
@@ -81,4 +82,4 @@ def crop(img, point, mode=0, size=(512, 512), box=None, face_ratio=3, shreshold=
|
|
81 |
|
82 |
cropped_img = img.crop((left, top, right, bottom))
|
83 |
cropped_img = cropped_img.resize(size)
|
84 |
-
return
|
|
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
5 |
|
6 |
+
def crop(image_path, point, mode=0, size=(512, 512), box=None, face_ratio=3, shreshold=1.5):
|
7 |
+
img = Image.open(image_path)
|
8 |
img_width, img_height = img.size
|
9 |
tgt_width, tgt_height = size
|
10 |
point = (point[0]*img_width, point[1]*img_height)
|
|
|
82 |
|
83 |
cropped_img = img.crop((left, top, right, bottom))
|
84 |
cropped_img = cropped_img.resize(size)
|
85 |
+
return cropped_img
|