newtechdevng commited on
Commit
8143697
·
verified ·
1 Parent(s): a4c7ff4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -113,12 +113,12 @@ async def detect(
113
 
114
  detections.append({
115
  "class": cls,
116
- "confidence": conf,
117
- "bbox": [x1, y1, x2, y2],
118
- "width_px": w_px,
119
- "height_px": h_px,
120
- "width_cm": w_cm,
121
- "height_cm": h_cm,
122
  })
123
 
124
  # Encode result image
@@ -126,14 +126,14 @@ async def detect(
126
  img_b64 = base64.b64encode(buf).decode()
127
 
128
  return {
129
- "success": True,
130
- "calibrated": calibrated,
131
- "pixels_per_cm": round(pixels_per_cm, 2) if calibrated else None,
132
- "marker_size_cm": marker_size_cm,
133
- "inference_time_s": round(time.time() - start, 3),
134
- "total": len(detections),
135
- "detections": detections,
136
- "image_base64": img_b64,
137
  }
138
 
139
  if __name__ == "__main__":
 
113
 
114
  detections.append({
115
  "class": cls,
116
+ "confidence": float(conf),
117
+ "bbox": [int(x1), int(y1), int(x2), int(y2)],
118
+ "width_px": int(w_px),
119
+ "height_px": int(h_px),
120
+ "width_cm": float(w_cm) if w_cm is not None else None,
121
+ "height_cm": float(h_cm) if h_cm is not None else None,
122
  })
123
 
124
  # Encode result image
 
126
  img_b64 = base64.b64encode(buf).decode()
127
 
128
  return {
129
+ "success": True,
130
+ "calibrated": bool(calibrated),
131
+ "pixels_per_cm": float(round(pixels_per_cm, 2)) if calibrated else None,
132
+ "marker_size_cm": float(marker_size_cm),
133
+ "inference_time_s": float(round(time.time() - start, 3)),
134
+ "total": int(len(detections)),
135
+ "detections": detections,
136
+ "image_base64": img_b64,
137
  }
138
 
139
  if __name__ == "__main__":