Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -80,18 +80,16 @@ 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
  milestones.append(milestone)
97
 
 
80
  except Exception as e:
81
  return f"Error: Failed to upload image to Salesforce - {str(e)}", "Failure", "", "", 0
82
 
83
+ # Use file name to detect milestones as a fallback (simple keyword-based detection)
84
+ milestone = "Planning" # Default if no match is found
85
+ image_filename_lower = image_filename.lower()
 
 
86
 
87
+ if any(keyword in image_filename_lower for keyword in ["foundation", "excavation", "digging"]):
88
+ milestone = "Foundation"
89
+ elif any(keyword in image_filename_lower for keyword in ["walls", "framing", "structure"]):
90
+ milestone = "Walls Erected"
91
+ elif any(keyword in image_filename_lower for keyword in ["completed", "final", "finished"]):
92
+ milestone = "Completed"
93
 
94
  milestones.append(milestone)
95