Spaces:
Sleeping
Sleeping
| 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() | |