Kushalmanda commited on
Commit
1aaad69
·
verified ·
1 Parent(s): b831d17

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -31,7 +31,7 @@ def calculate_materials(detected_objects, image_width, image_height):
31
  materials['bricks'] += area * 10 # Bricks estimation
32
  materials['steel'] += area * 0.05 # Steel estimation
33
 
34
- if obj['name'] == 'foundation': # Example: For 'foundation' objects
35
  materials['cement'] += area * 0.2 # More cement for foundation
36
  materials['bricks'] += area * 15 # More bricks for foundation
37
  materials['steel'] += area * 0.1 # More steel for foundation
@@ -49,6 +49,10 @@ def predict_image(image):
49
  # Print out the detection results for debugging purposes
50
  print(f"Detected objects: {detected_objects}")
51
 
 
 
 
 
52
  # Assume blueprint image size (in cm, adjust based on real-world image size)
53
  image_width = 91 # Example width in cm (adjust this)
54
  image_height = 61 # Example height in cm (adjust this)
@@ -57,7 +61,7 @@ def predict_image(image):
57
  detected_objects_list = []
58
  for _, row in detected_objects.iterrows():
59
  detected_objects_list.append({
60
- 'name': row['name'], # Detected object class name (e.g., 'wall', 'foundation')
61
  'bbox': [row['xmin'], row['ymin'], row['xmax'], row['ymax']] # Bounding box coordinates
62
  })
63
 
 
31
  materials['bricks'] += area * 10 # Bricks estimation
32
  materials['steel'] += area * 0.05 # Steel estimation
33
 
34
+ elif obj['name'] == 'foundation': # Example: For 'foundation' objects
35
  materials['cement'] += area * 0.2 # More cement for foundation
36
  materials['bricks'] += area * 15 # More bricks for foundation
37
  materials['steel'] += area * 0.1 # More steel for foundation
 
49
  # Print out the detection results for debugging purposes
50
  print(f"Detected objects: {detected_objects}")
51
 
52
+ # Set the confidence threshold (e.g., 0.5 means 50% confidence)
53
+ confidence_threshold = 0.5
54
+ detected_objects = detected_objects[detected_objects['confidence'] > confidence_threshold]
55
+
56
  # Assume blueprint image size (in cm, adjust based on real-world image size)
57
  image_width = 91 # Example width in cm (adjust this)
58
  image_height = 61 # Example height in cm (adjust this)
 
61
  detected_objects_list = []
62
  for _, row in detected_objects.iterrows():
63
  detected_objects_list.append({
64
+ 'name': row['name'], # Detected object class name (e.g., 'wall', 'foundation')
65
  'bbox': [row['xmin'], row['ymin'], row['xmax'], row['ymax']] # Bounding box coordinates
66
  })
67