Spaces:
Runtime error
Runtime error
Download test.py from reidddd/carDamageDetection: direct link, hf CLI and curl.
- Browser
- Download file 513 Bytes
-
https://huggingface.co/spaces/reidddd/carDamageDetection/resolve/main/test.py
- Command line
-
hf download hf://spaces/reidddd/carDamageDetection/test.py
-
curl -L -o test.py https://huggingface.co/spaces/reidddd/carDamageDetection/resolve/main/test.py
513 Bytes
| import cv2 | |
| import numpy as np | |
| def is_mri_image(image_path): | |
| img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE) | |
| if img is None: | |
| return False # Invalid image | |
| # Apply Canny edge detection | |
| edges = cv2.Canny(img, 50, 150) | |
| # Calculate edge density (MRI images have high edge presence) | |
| edge_density = np.sum(edges > 0) / edges.size | |
| print(edge_density) | |
| return edge_density > 0.05 # Threshold from MRI dataset | |
| # Test on an MRI or non-MRI image | |
| print(is_mri_image("a.png")) | |