Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,6 +107,30 @@ def process_image(image, project_name):
|
|
| 107 |
# AI-based milestone and completion prediction
|
| 108 |
milestone, percent_complete, confidence_score = mock_ai_model(img)
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# Adjust the current time to local timezone
|
| 111 |
local_time = datetime.now(local_timezone).strftime("%Y-%m-%dT%H:%M:%S%z") # Corrected ISO 8601 format with timezone
|
| 112 |
|
|
@@ -127,13 +151,21 @@ def process_image(image, project_name):
|
|
| 127 |
except Exception as e:
|
| 128 |
return f"Error: Failed to update Salesforce - {str(e)}", "Failure", "", "", 0
|
| 129 |
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
except Exception as e:
|
| 139 |
return f"Error: {str(e)}", "Failure", "", "", 0
|
|
|
|
| 107 |
# AI-based milestone and completion prediction
|
| 108 |
milestone, percent_complete, confidence_score = mock_ai_model(img)
|
| 109 |
|
| 110 |
+
# Detailed Completion Breakdown (based on detected milestone)
|
| 111 |
+
completion_details = {
|
| 112 |
+
"Planning": {
|
| 113 |
+
"completed": "Project outline and goals set, initial designs done.",
|
| 114 |
+
"not_completed": "Detailed plans, permits, and contractor hiring pending."
|
| 115 |
+
},
|
| 116 |
+
"Foundation": {
|
| 117 |
+
"completed": "Foundation work is complete, concrete is poured.",
|
| 118 |
+
"not_completed": "Plumbing, electrical groundwork not yet done."
|
| 119 |
+
},
|
| 120 |
+
"Walls Erected": {
|
| 121 |
+
"completed": "All structural walls are up.",
|
| 122 |
+
"not_completed": "Roofing, windows, and internal walls are not yet finished."
|
| 123 |
+
},
|
| 124 |
+
"Completed": {
|
| 125 |
+
"completed": "All phases of the project are finished, including final touches.",
|
| 126 |
+
"not_completed": "There should be no more pending work."
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
# Get the detailed completion information based on the detected milestone
|
| 131 |
+
completed_work = completion_details[milestone]["completed"]
|
| 132 |
+
not_completed_work = completion_details[milestone]["not_completed"]
|
| 133 |
+
|
| 134 |
# Adjust the current time to local timezone
|
| 135 |
local_time = datetime.now(local_timezone).strftime("%Y-%m-%dT%H:%M:%S%z") # Corrected ISO 8601 format with timezone
|
| 136 |
|
|
|
|
| 151 |
except Exception as e:
|
| 152 |
return f"Error: Failed to update Salesforce - {str(e)}", "Failure", "", "", 0
|
| 153 |
|
| 154 |
+
# Return the detailed result
|
| 155 |
+
result = f"""
|
| 156 |
+
Milestone: {milestone}
|
| 157 |
+
Completion Percentage: {percent_complete}%
|
| 158 |
+
|
| 159 |
+
**Completed Work**:
|
| 160 |
+
{completed_work}
|
| 161 |
+
|
| 162 |
+
**Not Completed Work**:
|
| 163 |
+
{not_completed_work}
|
| 164 |
+
|
| 165 |
+
Confidence Score: {confidence_score * 100}%
|
| 166 |
+
"""
|
| 167 |
+
|
| 168 |
+
return result, "Success", milestone, f"Confidence Score: {confidence_score}", percent_complete
|
| 169 |
|
| 170 |
except Exception as e:
|
| 171 |
return f"Error: {str(e)}", "Failure", "", "", 0
|