Rekham1110 commited on
Commit
22bf28a
·
verified ·
1 Parent(s): 71ef5da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -49,10 +49,11 @@ def analyze_image_with_hf(image_path):
49
  gray_pixels = sum(1 for pixel in img_data if sum(pixel[:3]) / 3 < 128) / len(img_data)
50
  color_variance = statistics.variance([sum(pixel[:3]) / 3 for pixel in img_data]) if len(img_data) > 1 else 0
51
 
52
- # Adjusted logic to detect completed construction
53
- if total_pixels > 800000 and gray_pixels < 0.4 and color_variance > 2000 and any(keyword in os.path.basename(image_path).lower() or any(elem in img_data for elem in ["window", "door", "roof"]) for keyword in ["window", "door", "roof"]):
 
54
  detected_elements.extend(["roof", "windows", "doors", "cladding", "finished"])
55
- elif total_pixels < 200000 or (color_variance < 800 and total_pixels < 500000):
56
  detected_elements.append("planning")
57
  elif gray_pixels > 0.6 and total_pixels > 400000:
58
  detected_elements.append("foundation")
@@ -214,7 +215,7 @@ def process_image(images, project_name):
214
  {completed_html}
215
  </ul>
216
  </details>
217
- <p style="color: green;">Project is fully completed as of 02:30 PM IST, June 20, 2025.</p>
218
  </div>
219
  """
220
  else:
@@ -252,7 +253,7 @@ def process_image(images, project_name):
252
  {not_completed_html}
253
  </ul>
254
  </details>
255
- <p style="color: orange;">Construction is in progress at {final_milestone} stage as of 02:30 PM IST, June 20, 2025.</p>
256
  </div>
257
  """
258
 
@@ -263,8 +264,8 @@ def process_image(images, project_name):
263
 
264
  combined_html = "<div>" + "".join(results_html) + "</div>"
265
 
266
- # Set current time to 02:30 PM IST, June 20, 2025
267
- now = local_timezone.localize(datetime(2025, 6, 20, 14, 30))
268
  local_time = now.strftime("%Y-%m-%dT%H:%M:%S") + now.strftime("%z")[:-2] + ":" + now.strftime("%z")[-2:]
269
 
270
  record = {
 
49
  gray_pixels = sum(1 for pixel in img_data if sum(pixel[:3]) / 3 < 128) / len(img_data)
50
  color_variance = statistics.variance([sum(pixel[:3]) / 3 for pixel in img_data]) if len(img_data) > 1 else 0
51
 
52
+ # Adjusted logic to detect completed construction, overriding small size
53
+ if (color_variance > 2000 and gray_pixels < 0.4 and any(keyword in os.path.basename(image_path).lower() for keyword in ["window", "door", "roof"])) or \
54
+ (total_pixels > 800000 and gray_pixels < 0.4 and color_variance > 2000):
55
  detected_elements.extend(["roof", "windows", "doors", "cladding", "finished"])
56
+ elif total_pixels < 200000 and color_variance < 800:
57
  detected_elements.append("planning")
58
  elif gray_pixels > 0.6 and total_pixels > 400000:
59
  detected_elements.append("foundation")
 
215
  {completed_html}
216
  </ul>
217
  </details>
218
+ <p style="color: green;">Project is fully completed as of 02:35 PM IST, June 20, 2025.</p>
219
  </div>
220
  """
221
  else:
 
253
  {not_completed_html}
254
  </ul>
255
  </details>
256
+ <p style="color: orange;">Construction is in progress at {final_milestone} stage as of 02:35 PM IST, June 20, 2025.</p>
257
  </div>
258
  """
259
 
 
264
 
265
  combined_html = "<div>" + "".join(results_html) + "</div>"
266
 
267
+ # Set current time to 02:35 PM IST, June 20, 2025
268
+ now = local_timezone.localize(datetime(2025, 6, 20, 14, 35))
269
  local_time = now.strftime("%Y-%m-%dT%H:%M:%S") + now.strftime("%z")[:-2] + ":" + now.strftime("%z")[-2:]
270
 
271
  record = {