Spaces:
Sleeping
Sleeping
longhodac commited on
Commit ·
bf32e4b
1
Parent(s): c380d92
fixed age dtection model and added some scripting files
Browse files
Long-test-model-scripts/output_age.jpg
ADDED
|
Long-test-model-scripts/output_race.jpg
CHANGED
|
|
Long-test-model-scripts/test_age.py
CHANGED
|
@@ -12,7 +12,7 @@ from deepface import DeepFace
|
|
| 12 |
|
| 13 |
|
| 14 |
# --- config ---
|
| 15 |
-
IMG_PATH = "data/test_images/5_images_baby_cute_face/
|
| 16 |
TFLITE_PATH = "models/age_model_single_batch.tflite"
|
| 17 |
|
| 18 |
DETECTOR_BACKEND = "opencv" # try "retinaface" for better alignment, slower [page:0]
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
# --- config ---
|
| 15 |
+
IMG_PATH = "data/test_images/5_images_baby_cute_face/5.jpg"
|
| 16 |
TFLITE_PATH = "models/age_model_single_batch.tflite"
|
| 17 |
|
| 18 |
DETECTOR_BACKEND = "opencv" # try "retinaface" for better alignment, slower [page:0]
|
Long-test-model-scripts/test_deepface.py
CHANGED
|
@@ -2,13 +2,17 @@
|
|
| 2 |
Quick test script for DeepFace models
|
| 3 |
"""
|
| 4 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
sys.path.append('app')
|
| 6 |
|
| 7 |
from model.deepfaceLiteDetection import Race_Detection, Gender_Detection, Age_Detection
|
| 8 |
import cv2
|
| 9 |
|
| 10 |
# Test image path
|
| 11 |
-
test_image = "
|
| 12 |
|
| 13 |
print("=" * 50)
|
| 14 |
print("Testing DeepFace Models")
|
|
@@ -22,7 +26,7 @@ try:
|
|
| 22 |
print(f" Detected races: {races}")
|
| 23 |
print(f" Face locations: {locations}")
|
| 24 |
if frame is not None:
|
| 25 |
-
cv2.imwrite("output_race.jpg", frame)
|
| 26 |
print(" Saved output to: output_race.jpg")
|
| 27 |
except Exception as e:
|
| 28 |
print(f" Error: {e}")
|
|
@@ -44,6 +48,12 @@ try:
|
|
| 44 |
ages, locations, frame = age_detector.findFrameWithFace(test_image)
|
| 45 |
print(f" Detected ages: {ages}")
|
| 46 |
print(f" Face locations: {locations}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
except Exception as e:
|
| 48 |
print(f" Error: {e}")
|
| 49 |
|
|
|
|
| 2 |
Quick test script for DeepFace models
|
| 3 |
"""
|
| 4 |
import sys
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
# Change to project root so all relative model paths resolve correctly
|
| 8 |
+
os.chdir(os.path.join(os.path.dirname(__file__), '..'))
|
| 9 |
sys.path.append('app')
|
| 10 |
|
| 11 |
from model.deepfaceLiteDetection import Race_Detection, Gender_Detection, Age_Detection
|
| 12 |
import cv2
|
| 13 |
|
| 14 |
# Test image path
|
| 15 |
+
test_image = "data/test_images/5_images_original/7.jpg"
|
| 16 |
|
| 17 |
print("=" * 50)
|
| 18 |
print("Testing DeepFace Models")
|
|
|
|
| 26 |
print(f" Detected races: {races}")
|
| 27 |
print(f" Face locations: {locations}")
|
| 28 |
if frame is not None:
|
| 29 |
+
cv2.imwrite("Long-test-model-scripts/output_race.jpg", frame)
|
| 30 |
print(" Saved output to: output_race.jpg")
|
| 31 |
except Exception as e:
|
| 32 |
print(f" Error: {e}")
|
|
|
|
| 48 |
ages, locations, frame = age_detector.findFrameWithFace(test_image)
|
| 49 |
print(f" Detected ages: {ages}")
|
| 50 |
print(f" Face locations: {locations}")
|
| 51 |
+
if frame is not None:
|
| 52 |
+
for i, (y, x, y2, x2) in enumerate(locations):
|
| 53 |
+
cv2.rectangle(frame, (x, y), (x2, y2), (255, 0, 0), 2)
|
| 54 |
+
cv2.putText(frame, f"Age: {ages[i]}", (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (255, 0, 0), 2)
|
| 55 |
+
cv2.imwrite("Long-test-model-scripts/output_age.jpg", frame)
|
| 56 |
+
print(" Saved output to: output_age.jpg")
|
| 57 |
except Exception as e:
|
| 58 |
print(f" Error: {e}")
|
| 59 |
|