Spaces:
Build error
Build error
Fix wrong path
Browse files
detect.py
CHANGED
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
|
| 6 |
-
def detect(image_pil, cascade_file="
|
| 7 |
cascade = cv2.CascadeClassifier(cascade_file)
|
| 8 |
|
| 9 |
image = np.array(image_pil)
|
|
@@ -24,10 +24,4 @@ def detect(image_pil, cascade_file="app/lbpcascade_animeface.xml"):
|
|
| 24 |
x, y, w, h = faces[0]
|
| 25 |
face = image[y : y + h, x : x + w]
|
| 26 |
|
| 27 |
-
return Image.fromarray(face)
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
if __name__ == "__main__":
|
| 31 |
-
p = "app/detector/3000.jpg"
|
| 32 |
-
img = Image.open(p)
|
| 33 |
-
detect(img)
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
|
| 6 |
+
def detect(image_pil, cascade_file="lbpcascade_animeface.xml"):
|
| 7 |
cascade = cv2.CascadeClassifier(cascade_file)
|
| 8 |
|
| 9 |
image = np.array(image_pil)
|
|
|
|
| 24 |
x, y, w, h = faces[0]
|
| 25 |
face = image[y : y + h, x : x + w]
|
| 26 |
|
| 27 |
+
return Image.fromarray(face)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|