chandra7799 commited on
Commit
07bdf30
·
verified ·
1 Parent(s): 32efefd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -40,7 +40,7 @@ local_timezone = pytz.timezone("Asia/Kolkata")
40
  # Image processing and Salesforce upload
41
  def process_image(images, project_name):
42
  try:
43
- if not images or not isinstance(images, list):
44
  return "Error: Please upload at least one image to proceed.", "Pending", "", "", 0
45
 
46
  # Process each image
@@ -87,9 +87,9 @@ def process_image(images, project_name):
87
  milestone = VALID_MILESTONES[milestone_index]
88
 
89
  # Adjust milestone detection based on internal/external features
90
- if milestone == "Walls Erected" and any("interior" in img_text.lower() for img_text in [img.filename] if img_text):
91
  # Check for visible internal works like electrical/plumbing
92
- if any(keyword in str(img).lower() for keyword in ["electrical", "plumbing", "wiring", "pipes"]):
93
  milestone = "Completed" # Upgrade to Completed if internal works are detected
94
  else:
95
  milestone = "Walls Erected" # Retain if no internal works visible
@@ -285,7 +285,7 @@ with gr.Blocks(css="""
285
  """) as demo:
286
  gr.Markdown("<h1 class='title'>Construction Progress Analyzer</h1>")
287
  with gr.Row():
288
- image_input = gr.Image(type="filepath", label="Upload Construction Site Photos (JPG/PNG, ≤ 20MB)", file_count="multiple")
289
  project_name_input = gr.Textbox(label="Project Name (Required)", placeholder="e.g. Project_12345")
290
 
291
  submit_button = gr.Button("Process Image")
 
40
  # Image processing and Salesforce upload
41
  def process_image(images, project_name):
42
  try:
43
+ if not images or len(images) == 0:
44
  return "Error: Please upload at least one image to proceed.", "Pending", "", "", 0
45
 
46
  # Process each image
 
87
  milestone = VALID_MILESTONES[milestone_index]
88
 
89
  # Adjust milestone detection based on internal/external features
90
+ if milestone == "Walls Erected" and any("interior" in img_text.lower() for img_text in [os.path.basename(image)] if img_text):
91
  # Check for visible internal works like electrical/plumbing
92
+ if any(keyword in str(os.path.basename(image)).lower() for keyword in ["electrical", "plumbing", "wiring", "pipes"]):
93
  milestone = "Completed" # Upgrade to Completed if internal works are detected
94
  else:
95
  milestone = "Walls Erected" # Retain if no internal works visible
 
285
  """) as demo:
286
  gr.Markdown("<h1 class='title'>Construction Progress Analyzer</h1>")
287
  with gr.Row():
288
+ image_input = gr.Files(type="filepath", label="Upload Construction Site Photos (JPG/PNG, ≤ 20MB)")
289
  project_name_input = gr.Textbox(label="Project Name (Required)", placeholder="e.g. Project_12345")
290
 
291
  submit_button = gr.Button("Process Image")