Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -64,7 +64,7 @@ def analyze_image_with_hf(image_path):
|
|
| 64 |
|
| 65 |
return detected_elements
|
| 66 |
|
| 67 |
-
# Image processing and Salesforce upload
|
| 68 |
def process_image(images, project_name):
|
| 69 |
try:
|
| 70 |
if not images or len(images) == 0:
|
|
@@ -184,43 +184,77 @@ def process_image(images, project_name):
|
|
| 184 |
completed_html = "".join([f'<li style="color: green;">✔ {task}</li>' for task in completed_tasks])
|
| 185 |
not_completed_html = "".join([f'<li style="color: red;">✘ {task}</li>' for task in not_completed_tasks])
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
<div style="
|
| 191 |
-
<
|
| 192 |
-
|
| 193 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
</div>
|
| 195 |
-
<
|
| 196 |
-
|
| 197 |
-
<
|
| 198 |
-
<
|
|
|
|
|
|
|
|
|
|
| 199 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
</div>
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
<
|
| 206 |
-
<
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
</div>
|
| 209 |
-
|
| 210 |
-
<summary style="color: #2c3e50; font-weight: bold;">Completed Tasks</summary>
|
| 211 |
-
<ul style="padding-left: 20px;">
|
| 212 |
-
{completed_html}
|
| 213 |
-
</ul>
|
| 214 |
-
</details>
|
| 215 |
-
<details style="margin-bottom: 20px;">
|
| 216 |
-
<summary style="color: #2c3e50; font-weight: bold;">Not Completed Tasks</summary>
|
| 217 |
-
<ul style="padding-left: 20px;">
|
| 218 |
-
{not_completed_html}
|
| 219 |
-
</ul>
|
| 220 |
-
</details>
|
| 221 |
-
<p style="color: orange;">Note: Image upload to Salesforce was skipped due to storage limit. Results are based on local analysis.</p>
|
| 222 |
-
</div>
|
| 223 |
-
"""
|
| 224 |
|
| 225 |
results_html.append(result_html)
|
| 226 |
upload_statuses.append("Success" if file_url != "Upload skipped due to storage limit" else "Pending")
|
|
@@ -229,8 +263,8 @@ def process_image(images, project_name):
|
|
| 229 |
|
| 230 |
combined_html = "<div>" + "".join(results_html) + "</div>"
|
| 231 |
|
| 232 |
-
# Set current time to
|
| 233 |
-
now = local_timezone.localize(datetime(2025, 6, 20,
|
| 234 |
local_time = now.strftime("%Y-%m-%dT%H:%M:%S") + now.strftime("%z")[:-2] + ":" + now.strftime("%z")[-2:]
|
| 235 |
|
| 236 |
record = {
|
|
|
|
| 64 |
|
| 65 |
return detected_elements
|
| 66 |
|
| 67 |
+
# Image processing and Salesforce upload with sample outputs
|
| 68 |
def process_image(images, project_name):
|
| 69 |
try:
|
| 70 |
if not images or len(images) == 0:
|
|
|
|
| 184 |
completed_html = "".join([f'<li style="color: green;">✔ {task}</li>' for task in completed_tasks])
|
| 185 |
not_completed_html = "".join([f'<li style="color: red;">✘ {task}</li>' for task in not_completed_tasks])
|
| 186 |
|
| 187 |
+
# Sample output based on milestone
|
| 188 |
+
if final_milestone == "Completed":
|
| 189 |
+
result_html = f"""
|
| 190 |
+
<div style="font-family: Arial, sans-serif; padding: 20px; background-color: #f9f9f9; border-radius: 10px; margin-bottom: 20px;">
|
| 191 |
+
<h2 style="color: #2c3e50; text-align: center;">Project Summary - {os.path.basename(image)}</h2>
|
| 192 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 20px;">
|
| 193 |
+
<div style="text-align: center;">
|
| 194 |
+
<h3 style="color: #34495e;">Detected Milestone</h3>
|
| 195 |
+
<p style="font-size: 18px; font-weight: bold;">{final_milestone}</p>
|
| 196 |
+
</div>
|
| 197 |
+
<div style="text-align: center;">
|
| 198 |
+
<h3 style="color: #34495e;">Completion</h3>
|
| 199 |
+
<progress value="{percent_complete}" max="100" style="width: 200px; height: 20px;"></progress>
|
| 200 |
+
<p>{percent_complete}%</p>
|
| 201 |
+
</div>
|
| 202 |
</div>
|
| 203 |
+
<h3 style="color: #2c3e50;">Milestone Timeline</h3>
|
| 204 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
| 205 |
+
<span style="color: #bdc3c7;">Planning</span>
|
| 206 |
+
<span style="color: #bdc3c7;">Foundation</span>
|
| 207 |
+
<span style="color: #bdc3c7;">Walls Erected</span>
|
| 208 |
+
<span style="color: #bdc3c7;">Interior Furnishing</span>
|
| 209 |
+
<span style="color: #2ecc71;">Completed</span>
|
| 210 |
</div>
|
| 211 |
+
<details style="margin-bottom: 20px;">
|
| 212 |
+
<summary style="color: #2c3e50; font-weight: bold;">Completed Tasks</summary>
|
| 213 |
+
<ul style="padding-left: 20px;">
|
| 214 |
+
{completed_html}
|
| 215 |
+
</ul>
|
| 216 |
+
</details>
|
| 217 |
+
<p style="color: green;">Project is fully completed as of 11:23 AM IST, June 20, 2025.</p>
|
| 218 |
</div>
|
| 219 |
+
"""
|
| 220 |
+
else:
|
| 221 |
+
result_html = f"""
|
| 222 |
+
<div style="font-family: Arial, sans-serif; padding: 20px; background-color: #f9f9f9; border-radius: 10px; margin-bottom: 20px;">
|
| 223 |
+
<h2 style="color: #2c3e50; text-align: center;">Project Summary - {os.path.basename(image)}</h2>
|
| 224 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 20px;">
|
| 225 |
+
<div style="text-align: center;">
|
| 226 |
+
<h3 style="color: #34495e;">Detected Milestone</h3>
|
| 227 |
+
<p style="font-size: 18px; font-weight: bold;">{final_milestone}</p>
|
| 228 |
+
</div>
|
| 229 |
+
<div style="text-align: center;">
|
| 230 |
+
<h3 style="color: #34495e;">Completion</h3>
|
| 231 |
+
<progress value="{percent_complete}" max="100" style="width: 200px; height: 20px;"></progress>
|
| 232 |
+
<p>{percent_complete}%</p>
|
| 233 |
+
</div>
|
| 234 |
+
</div>
|
| 235 |
+
<h3 style="color: #2c3e50;">Milestone Timeline</h3>
|
| 236 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
|
| 237 |
+
<span style="color: {'#2ecc71' if final_milestone == 'Planning' else '#bdc3c7'};">Planning</span>
|
| 238 |
+
<span style="color: {'#2ecc71' if final_milestone == 'Foundation' else '#bdc3c7'};">Foundation</span>
|
| 239 |
+
<span style="color: {'#2ecc71' if final_milestone == 'Walls Erected' else '#bdc3c7'};">Walls Erected</span>
|
| 240 |
+
<span style="color: {'#2ecc71' if final_milestone == 'Interior Furnishing' else '#bdc3c7'};">Interior Furnishing</span>
|
| 241 |
+
<span style="color: {'#2ecc71' if final_milestone == 'Completed' else '#bdc3c7'};">Completed</span>
|
| 242 |
+
</div>
|
| 243 |
+
<details style="margin-bottom: 20px;">
|
| 244 |
+
<summary style="color: #2c3e50; font-weight: bold;">Completed Tasks</summary>
|
| 245 |
+
<ul style="padding-left: 20px;">
|
| 246 |
+
{completed_html}
|
| 247 |
+
</ul>
|
| 248 |
+
</details>
|
| 249 |
+
<details style="margin-bottom: 20px;">
|
| 250 |
+
<summary style="color: #2c3e50; font-weight: bold;">Not Completed Tasks</summary>
|
| 251 |
+
<ul style="padding-left: 20px;">
|
| 252 |
+
{not_completed_html}
|
| 253 |
+
</ul>
|
| 254 |
+
</details>
|
| 255 |
+
<p style="color: orange;">Construction is in progress at {final_milestone} stage as of 11:23 AM IST, June 20, 2025.</p>
|
| 256 |
</div>
|
| 257 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
results_html.append(result_html)
|
| 260 |
upload_statuses.append("Success" if file_url != "Upload skipped due to storage limit" else "Pending")
|
|
|
|
| 263 |
|
| 264 |
combined_html = "<div>" + "".join(results_html) + "</div>"
|
| 265 |
|
| 266 |
+
# Set current time to 11:23 AM IST, June 20, 2025
|
| 267 |
+
now = local_timezone.localize(datetime(2025, 6, 20, 11, 23))
|
| 268 |
local_time = now.strftime("%Y-%m-%dT%H:%M:%S") + now.strftime("%z")[:-2] + ":" + now.strftime("%z")[-2:]
|
| 269 |
|
| 270 |
record = {
|