chandra7799 commited on
Commit
e9e540d
·
verified ·
1 Parent(s): 3622dfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
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
- # Mock AI model to detect milestone based on image content
84
- img_bytes = img.tobytes()
85
- img_hash = int(hashlib.sha256(img_bytes).hexdigest(), 16)
86
- milestone_index = img_hash % len(VALID_MILESTONES)
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
- if any(keyword in str(os.path.basename(image)).lower() for keyword in ["electrical", "plumbing", "wiring", "pipes"]):
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