Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,11 @@ def preprocess_image(image_path):
|
|
| 7 |
# Read image
|
| 8 |
img = cv2.imread(image_path)
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Convert to grayscale
|
| 11 |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 12 |
|
|
@@ -58,10 +63,17 @@ def remove_shadows(image):
|
|
| 58 |
|
| 59 |
return result
|
| 60 |
|
| 61 |
-
def main(
|
|
|
|
|
|
|
|
|
|
| 62 |
# Step 1: Preprocess image
|
| 63 |
img, blurred = preprocess_image(image_path)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# Step 2: Detect edges
|
| 66 |
edges = detect_edges(blurred)
|
| 67 |
|
|
@@ -88,5 +100,4 @@ def main(image_path):
|
|
| 88 |
plt.show()
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
| 91 |
-
|
| 92 |
-
main(image_path)
|
|
|
|
| 7 |
# Read image
|
| 8 |
img = cv2.imread(image_path)
|
| 9 |
|
| 10 |
+
# Check if the image is loaded correctly
|
| 11 |
+
if img is None:
|
| 12 |
+
print(f"Error: Unable to load image at {image_path}")
|
| 13 |
+
return None, None
|
| 14 |
+
|
| 15 |
# Convert to grayscale
|
| 16 |
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
| 17 |
|
|
|
|
| 63 |
|
| 64 |
return result
|
| 65 |
|
| 66 |
+
def main():
|
| 67 |
+
# Ask the user to provide the image path
|
| 68 |
+
image_path = input("Please provide the path to the rooftop image (e.g., 'image.jpg'): ")
|
| 69 |
+
|
| 70 |
# Step 1: Preprocess image
|
| 71 |
img, blurred = preprocess_image(image_path)
|
| 72 |
|
| 73 |
+
# If the image was not loaded successfully, exit the program
|
| 74 |
+
if img is None:
|
| 75 |
+
return
|
| 76 |
+
|
| 77 |
# Step 2: Detect edges
|
| 78 |
edges = detect_edges(blurred)
|
| 79 |
|
|
|
|
| 100 |
plt.show()
|
| 101 |
|
| 102 |
if __name__ == "__main__":
|
| 103 |
+
main()
|
|
|