2up1down commited on
Commit
de8d03b
1 Parent(s): 555fc86

Upload app.py

Browse files

fix json serialization

Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -6,6 +6,7 @@ from ultralytics import YOLO
6
  from google.cloud import vision
7
  _api_key = os.environ["API_KEY"]
8
  _project_id = os.environ["PROJECT_ID"]
 
9
  client = vision.ImageAnnotatorClient(client_options={"quota_project_id": _project_id, "api_key": _api_key})
10
 
11
  import math
@@ -299,7 +300,7 @@ def get_needle_value(img, keypoints):
299
  debug(img, contents, keypoints)
300
 
301
  startValue= float(values[0]["value"])
302
- tipvalue= round(tipValues[nearestIx].mean(),2)
303
  endValue= float(values[-1]["value"])
304
 
305
  return {"startValue": startValue, "tipvalue": tipvalue, "endValue": endValue, "unitPerDeg": float(rate), "otherText": list(set(other))}
@@ -347,8 +348,10 @@ def predict(img, detect_gauge_first):
347
  angle2tip, totalAngle = calculate_sweep_angles(keypoints)
348
 
349
  payload = get_needle_value(phimg, keypoints)
350
- payload["angleToTip"] = round(angle2tip,2)
351
- payload["totalAngle"] = round(totalAngle,2)
 
 
352
 
353
  return payload
354
 
 
6
  from google.cloud import vision
7
  _api_key = os.environ["API_KEY"]
8
  _project_id = os.environ["PROJECT_ID"]
9
+
10
  client = vision.ImageAnnotatorClient(client_options={"quota_project_id": _project_id, "api_key": _api_key})
11
 
12
  import math
 
300
  debug(img, contents, keypoints)
301
 
302
  startValue= float(values[0]["value"])
303
+ tipvalue= round(float(tipValues[nearestIx].mean()),2)
304
  endValue= float(values[-1]["value"])
305
 
306
  return {"startValue": startValue, "tipvalue": tipvalue, "endValue": endValue, "unitPerDeg": float(rate), "otherText": list(set(other))}
 
348
  angle2tip, totalAngle = calculate_sweep_angles(keypoints)
349
 
350
  payload = get_needle_value(phimg, keypoints)
351
+ payload["angleToTip"] = round(float(angle2tip),2)
352
+ payload["totalAngle"] = round(float(totalAngle),2)
353
+ for k,v in payload.items():
354
+ print(k, type(v),v)
355
 
356
  return payload
357