Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,11 +50,16 @@ def detect_milestone_from_image(image_path):
|
|
| 50 |
|
| 51 |
def process_image(images, project_name):
|
| 52 |
try:
|
| 53 |
-
|
|
|
|
| 54 |
return "Error: Please upload at least one image to proceed.", "Pending", "", "", 0
|
| 55 |
|
| 56 |
milestones = []
|
| 57 |
for image in images:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
img = Image.open(image)
|
| 59 |
|
| 60 |
image_size_mb = os.path.getsize(image) / (1024 * 1024)
|
|
@@ -120,16 +125,15 @@ def process_image(images, project_name):
|
|
| 120 |
except Exception as e:
|
| 121 |
return f"Error: {str(e)}", "Failure", "", "", "0%"
|
| 122 |
|
| 123 |
-
# Gradio UI with
|
| 124 |
with gr.Blocks(css="") as demo:
|
| 125 |
gr.Markdown("<h1 class='title'>Construction Progress Analyzer</h1>")
|
| 126 |
with gr.Row():
|
| 127 |
-
# Changed from gr.Files to gr.Gallery for visual image preview
|
| 128 |
image_input = gr.Gallery(
|
| 129 |
label="Upload Construction Site Photos (JPG/PNG, ≤ 20MB)",
|
| 130 |
type="filepath",
|
| 131 |
interactive=True,
|
| 132 |
-
show_download_button=False,
|
| 133 |
show_share_button=False
|
| 134 |
)
|
| 135 |
project_name_input = gr.Textbox(label="Project Name (Required)", placeholder="e.g. Project_12345")
|
|
|
|
| 50 |
|
| 51 |
def process_image(images, project_name):
|
| 52 |
try:
|
| 53 |
+
# Ensure images is a list and not empty
|
| 54 |
+
if not images or len(images) == 0 or not isinstance(images, list):
|
| 55 |
return "Error: Please upload at least one image to proceed.", "Pending", "", "", 0
|
| 56 |
|
| 57 |
milestones = []
|
| 58 |
for image in images:
|
| 59 |
+
# Ensure each image is a valid file path
|
| 60 |
+
if not isinstance(image, str) or not os.path.isfile(image):
|
| 61 |
+
return "Error: Invalid image file.", "Failure", "", "", 0
|
| 62 |
+
|
| 63 |
img = Image.open(image)
|
| 64 |
|
| 65 |
image_size_mb = os.path.getsize(image) / (1024 * 1024)
|
|
|
|
| 125 |
except Exception as e:
|
| 126 |
return f"Error: {str(e)}", "Failure", "", "", "0%"
|
| 127 |
|
| 128 |
+
# Gradio UI with gallery input
|
| 129 |
with gr.Blocks(css="") as demo:
|
| 130 |
gr.Markdown("<h1 class='title'>Construction Progress Analyzer</h1>")
|
| 131 |
with gr.Row():
|
|
|
|
| 132 |
image_input = gr.Gallery(
|
| 133 |
label="Upload Construction Site Photos (JPG/PNG, ≤ 20MB)",
|
| 134 |
type="filepath",
|
| 135 |
interactive=True,
|
| 136 |
+
show_download_button=False,
|
| 137 |
show_share_button=False
|
| 138 |
)
|
| 139 |
project_name_input = gr.Textbox(label="Project Name (Required)", placeholder="e.g. Project_12345")
|