amobionovo commited on
Commit
09cf2bd
·
verified ·
1 Parent(s): 141460f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -0
handler.py CHANGED
@@ -46,6 +46,12 @@ class EndpointHandler:
46
  # ✅ Compatibility layer (does NOT break anything)
47
  payload = data.get("inputs", data)
48
 
 
 
 
 
 
 
49
  image_b64 = payload["image"]
50
  conf = float(payload.get("conf", 0.25))
51
  iou = float(payload.get("iou", 0.45))
 
46
  # ✅ Compatibility layer (does NOT break anything)
47
  payload = data.get("inputs", data)
48
 
49
+ # ✅ Robust guard: prevents KeyError and hard crashes
50
+ if not isinstance(payload, dict) or "image" not in payload:
51
+ return {
52
+ "error": "Missing required key: 'image'. Expected base64-encoded image."
53
+ }
54
+
55
  image_b64 = payload["image"]
56
  conf = float(payload.get("conf", 0.25))
57
  iou = float(payload.get("iou", 0.45))