Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import huggingface_hub
|
|
8 |
import insightface
|
9 |
import numpy as np
|
10 |
import onnxruntime as ort
|
|
|
11 |
|
12 |
TITLE = "insightface Person Detection"
|
13 |
DESCRIPTION = "https://github.com/deepinsight/insightface/tree/master/examples/person_detection"
|
@@ -45,8 +46,9 @@ def visualize(image: np.ndarray, bboxes: np.ndarray, vbboxes: np.ndarray) -> lis
|
|
45 |
x1, y1, x2, y2 = bbox
|
46 |
person_img = image[y1:y2, x1:x2]
|
47 |
|
48 |
-
#
|
49 |
-
|
|
|
50 |
|
51 |
return person_images
|
52 |
|
@@ -60,7 +62,9 @@ def detect(image: np.ndarray) -> list[np.ndarray]:
|
|
60 |
image = image[:, :, ::-1] # RGB -> BGR
|
61 |
bboxes, vbboxes = detect_person(image, detector)
|
62 |
person_images = visualize(image, bboxes, vbboxes)
|
63 |
-
|
|
|
|
|
64 |
|
65 |
demo = gr.Interface(
|
66 |
fn=detect,
|
|
|
8 |
import insightface
|
9 |
import numpy as np
|
10 |
import onnxruntime as ort
|
11 |
+
from PIL import Image
|
12 |
|
13 |
TITLE = "insightface Person Detection"
|
14 |
DESCRIPTION = "https://github.com/deepinsight/insightface/tree/master/examples/person_detection"
|
|
|
46 |
x1, y1, x2, y2 = bbox
|
47 |
person_img = image[y1:y2, x1:x2]
|
48 |
|
49 |
+
# Convert numpy array to PIL Image and append
|
50 |
+
pil_img = Image.fromarray(person_img)
|
51 |
+
person_images.append(pil_img)
|
52 |
|
53 |
return person_images
|
54 |
|
|
|
62 |
image = image[:, :, ::-1] # RGB -> BGR
|
63 |
bboxes, vbboxes = detect_person(image, detector)
|
64 |
person_images = visualize(image, bboxes, vbboxes)
|
65 |
+
|
66 |
+
# Convert PIL images to numpy arrays and return
|
67 |
+
return [np.array(img) for img in person_images]
|
68 |
|
69 |
demo = gr.Interface(
|
70 |
fn=detect,
|