Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from PIL import Image
|
2 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
3 |
import numpy as np
|
|
|
4 |
from deepface import DeepFace
|
5 |
import gradio as gr
|
6 |
|
@@ -31,10 +32,15 @@ def analyze_image(image_pil):
|
|
31 |
out = model.generate(**inputs)
|
32 |
caption = processor.decode(out[0], skip_special_tokens=True)
|
33 |
|
34 |
-
#
|
|
|
|
|
|
|
35 |
try:
|
36 |
-
faces = DeepFace.extract_faces(img_path=
|
37 |
-
|
|
|
|
|
38 |
faces = []
|
39 |
|
40 |
face_infos = []
|
|
|
1 |
from PIL import Image
|
2 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
3 |
import numpy as np
|
4 |
+
import cv2
|
5 |
from deepface import DeepFace
|
6 |
import gradio as gr
|
7 |
|
|
|
32 |
out = model.generate(**inputs)
|
33 |
caption = processor.decode(out[0], skip_special_tokens=True)
|
34 |
|
35 |
+
# Convert to BGR for DeepFace
|
36 |
+
image_bgr = cv2.cvtColor(image_np, cv2.COLOR_RGB2BGR)
|
37 |
+
|
38 |
+
# Face detection using DeepFace with RetinaFace backend
|
39 |
try:
|
40 |
+
faces = DeepFace.extract_faces(img_path=image_bgr, detector_backend="retinaface", enforce_detection=False)
|
41 |
+
print(f"DeepFace detected {len(faces)} face(s)")
|
42 |
+
except Exception as e:
|
43 |
+
print("DeepFace error:", e)
|
44 |
faces = []
|
45 |
|
46 |
face_infos = []
|