Spaces:
Sleeping
Sleeping
File size: 1,311 Bytes
a5a6a2e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import os
import sys
# Ensure we can import from current directory
sys.path.append(os.getcwd())
from detect import detect_face_shape
TEST_DATASET_DIR = "../dataset/test"
def test():
with open("test_results.txt", "w") as f:
f.write("Starting simple accuracy test...\n")
if not os.path.exists(TEST_DATASET_DIR):
f.write(f"Dataset not found at {TEST_DATASET_DIR}\n")
return
classes = os.listdir(TEST_DATASET_DIR)
f.write(f"Classes found: {classes}\n")
for label in classes:
folder = os.path.join(TEST_DATASET_DIR, label)
if not os.path.isdir(folder):
continue
files = os.listdir(folder)
if not files:
f.write(f"No files in {label}\n")
continue
# Test just one image per class to verify pipeline
img_path = os.path.join(folder, files[0])
f.write(f"Testing {label} with {img_path}\n")
try:
result = detect_face_shape(img_path)
f.write(f"Result for {label}: {result}\n")
except Exception as e:
f.write(f"Error for {label}: {e}\n")
f.flush()
if __name__ == "__main__":
test()
|