Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,21 +43,22 @@ def analyze_image_with_hf(image_path):
|
|
| 43 |
img = Image.open(image_path)
|
| 44 |
detected_elements = []
|
| 45 |
|
| 46 |
-
# Enhanced mock detection based on
|
| 47 |
-
|
| 48 |
-
img_data = img.
|
| 49 |
-
|
|
|
|
| 50 |
|
| 51 |
-
# Heuristic detection based on
|
| 52 |
-
if
|
| 53 |
detected_elements.append("planning")
|
| 54 |
-
elif
|
| 55 |
detected_elements.append("foundation")
|
| 56 |
-
elif
|
| 57 |
detected_elements.append("walls")
|
| 58 |
-
elif any(keyword in
|
| 59 |
-
detected_elements.extend(["interior", "electrical_wiring", "plumbing_pipes"
|
| 60 |
-
|
| 61 |
detected_elements.extend(["roof", "windows", "doors", "cladding", "finished"])
|
| 62 |
|
| 63 |
return detected_elements
|
|
@@ -170,7 +171,7 @@ def process_image(images, project_name):
|
|
| 170 |
completed_tasks.extend(all_tasks["Walls Erected"])
|
| 171 |
final_milestone = "Walls Erected"
|
| 172 |
percent_complete = 50
|
| 173 |
-
elif
|
| 174 |
completed_tasks.extend(all_tasks["Interior Furnishing"])
|
| 175 |
final_milestone = "Interior Furnishing"
|
| 176 |
percent_complete = 80
|
|
|
|
| 43 |
img = Image.open(image_path)
|
| 44 |
detected_elements = []
|
| 45 |
|
| 46 |
+
# Enhanced mock detection based on image size and pixel data (simulating content analysis)
|
| 47 |
+
width, height = img.size
|
| 48 |
+
img_data = list(img.getdata())
|
| 49 |
+
gray_pixels = sum(1 for pixel in img_data if sum(pixel[:3]) / 3 < 128) / len(img_data) # Proportion of dark pixels
|
| 50 |
+
total_pixels = width * height
|
| 51 |
|
| 52 |
+
# Heuristic detection based on image characteristics
|
| 53 |
+
if total_pixels < 500000: # Small image size, assume early planning stage
|
| 54 |
detected_elements.append("planning")
|
| 55 |
+
elif gray_pixels > 0.6 and width > 1000: # High proportion of dark pixels, assume concrete/foundation
|
| 56 |
detected_elements.append("foundation")
|
| 57 |
+
elif gray_pixels > 0.4 and width > 1000 and height > 1000: # Larger structure with columns, assume walls erected
|
| 58 |
detected_elements.append("walls")
|
| 59 |
+
elif any(keyword in os.path.basename(image_path).lower() for keyword in ["interior", "plumbing", "electrical", "ceiling"]) or (gray_pixels < 0.3 and total_pixels > 800000): # Interior work or bright finished interior
|
| 60 |
+
detected_elements.extend(["interior", "electrical_wiring", "plumbing_pipes"])
|
| 61 |
+
else: # Assume completed if no other clear indicators
|
| 62 |
detected_elements.extend(["roof", "windows", "doors", "cladding", "finished"])
|
| 63 |
|
| 64 |
return detected_elements
|
|
|
|
| 171 |
completed_tasks.extend(all_tasks["Walls Erected"])
|
| 172 |
final_milestone = "Walls Erected"
|
| 173 |
percent_complete = 50
|
| 174 |
+
elif any(elem in ["interior", "electrical_wiring", "plumbing_pipes"] for elem in detected_elements_all):
|
| 175 |
completed_tasks.extend(all_tasks["Interior Furnishing"])
|
| 176 |
final_milestone = "Interior Furnishing"
|
| 177 |
percent_complete = 80
|