chandra7799 commited on
Commit
5a18414
·
verified ·
1 Parent(s): 155e3c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -81,16 +81,8 @@ def process_image(images, project_name):
81
  except Exception as e:
82
  return f"Error: Failed to upload image to Salesforce - {str(e)}", "Failure", "", "", 0
83
 
84
- # Checking for external features indicating completion
85
- # If image contains features suggesting a completed building (such as windows, doors, exterior finish)
86
- if "completed" in os.path.basename(image).lower() or "finished" in os.path.basename(image).lower():
87
- milestone = "Completed" # Directly detect completion if such features exist
88
- else:
89
- # Default milestone detection logic (mock AI model or image-based hash)
90
- img_bytes = img.tobytes()
91
- img_hash = int(hashlib.sha256(img_bytes).hexdigest(), 16)
92
- milestone_index = img_hash % len(VALID_MILESTONES)
93
- milestone = VALID_MILESTONES[milestone_index]
94
 
95
  milestones.append(milestone)
96
 
@@ -225,6 +217,22 @@ def process_image(images, project_name):
225
  except Exception as e:
226
  return f"Error: {str(e)}", "Failure", "", "", "0%"
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  # Gradio UI
229
  with gr.Blocks(css="""
230
  .gradio-container {
 
81
  except Exception as e:
82
  return f"Error: Failed to upload image to Salesforce - {str(e)}", "Failure", "", "", 0
83
 
84
+ # Enhanced Milestone Detection
85
+ milestone = detect_milestone(image)
 
 
 
 
 
 
 
 
86
 
87
  milestones.append(milestone)
88
 
 
217
  except Exception as e:
218
  return f"Error: {str(e)}", "Failure", "", "", "0%"
219
 
220
+ # Enhanced Milestone Detection based on image content or filename
221
+ def detect_milestone(image_path):
222
+ # Check the image filename for certain keywords that might indicate a milestone
223
+ image_name = os.path.basename(image_path).lower()
224
+ if "planning" in image_name:
225
+ return "Planning"
226
+ elif "foundation" in image_name:
227
+ return "Foundation"
228
+ elif "walls" in image_name or "erected" in image_name:
229
+ return "Walls Erected"
230
+ elif "completed" in image_name:
231
+ return "Completed"
232
+
233
+ # Default to Planning if no specific milestone found
234
+ return "Planning"
235
+
236
  # Gradio UI
237
  with gr.Blocks(css="""
238
  .gradio-container {