Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -80,22 +80,15 @@ def process_image(images, project_name):
|
|
| 80 |
except Exception as e:
|
| 81 |
return f"Error: Failed to upload image to Salesforce - {str(e)}", "Failure", "", "", 0
|
| 82 |
|
| 83 |
-
#
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
milestone = "Completed"
|
| 93 |
-
else:
|
| 94 |
-
milestone = "Walls Erected"
|
| 95 |
-
|
| 96 |
-
# Specifically checking for external features indicating completion
|
| 97 |
-
if "completed" in os.path.basename(image).lower():
|
| 98 |
-
milestone = "Completed" # Detect "completed" word or finished facade
|
| 99 |
|
| 100 |
milestones.append(milestone)
|
| 101 |
|
|
|
|
| 80 |
except Exception as e:
|
| 81 |
return f"Error: Failed to upload image to Salesforce - {str(e)}", "Failure", "", "", 0
|
| 82 |
|
| 83 |
+
# Check if the image represents a completed building
|
| 84 |
+
if "completed" in os.path.basename(image).lower() or "finished" in os.path.basename(image).lower():
|
| 85 |
+
milestone = "Completed" # Directly detect completion if such features exist
|
| 86 |
+
else:
|
| 87 |
+
# Default milestone detection logic (mock AI model or image-based hash)
|
| 88 |
+
img_bytes = img.tobytes()
|
| 89 |
+
img_hash = int(hashlib.sha256(img_bytes).hexdigest(), 16)
|
| 90 |
+
milestone_index = img_hash % len(VALID_MILESTONES)
|
| 91 |
+
milestone = VALID_MILESTONES[milestone_index]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
milestones.append(milestone)
|
| 94 |
|