Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FUNCTIONS_ENDPOINT_URL="http://127.0.0.1:9093/ruxailab-dev/us-central1"
40 changes: 40 additions & 0 deletions scripts/manual_caliberation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import requests
import numpy as np
import json
from dotenv import load_dotenv
load_dotenv()

#Enter firebase emulator functions url
URL = os.getenv("FUNCTIONS_ENDPOINT_URL")
URL +="/receiveCalibration"

# Prompt user for session_id
session_id = input("Enter session_id/calib_id/auth : ")

# Valid/cached payload
payload = {'session_id': session_id,
'model': {
#fake data for skipping calibration test
'555': {'100': {'predicted_x': [323.90849681142043, 348.1325107350691, 352.11766437720337, 344.2872787631914, 346.9109456867647, 344.0109769042308, 346.4458717658222, 351.49320186886246, 346.794515072804, 345.1038327019448, 346.2462928983009, 350.75410855973496, 346.8313111082193, 345.08050064433706, 345.43196678081, 323.5123720148616, 346.13452659513246, 369.64289918931684], 'predicted_y': [524.29513902606, 256.33161135047635, 238.22934088647972, 257.31242578346684, 353.9909519909238, 265.8898953228318, 259.71108506445, 240.47681332752592, 257.0664933229692, 255.08531429844163, 252.78833266783124, 294.90515872178526, 258.48904131345773, 246.3226192890393, 262.71887523673456, 450.0961498301347, 244.52203642852834, 342.4681247239175], 'PrecisionSD': np.float64(0.9430907093135398), 'Accuracy': np.float64(1.4092187934882952)}, '393': {'predicted_x': [438.95506230826254, 384.90609223368983, 425.2242522635777, 394.16442258204734, 469.61390302270365, 433.6206920322056, 311.2109940406747, 477.1765213012511, 403.507005259926, 416.9411707708682, 469.1248741489944, 310.0520751020746, 588.7787722681376, 309.7967287584508, 436.39496116667783, 426.6539172979485, 380.7262944965772], 'predicted_y': [335.001704717649, 307.2147643506039, 333.33672469399846, 293.245566048315, 202.39824328051117, 154.08672107288993, 407.2395083869231, 136.33887328695727, 332.9909996739352, 279.31912253136795, 283.257000802475, 494.2446857288505, 238.0978435263185, 443.2060007400695, 345.660914639975, 268.56658929820526, 360.45074784535694], 'PrecisionSD': np.float64(1.1352791282910164), 'Accuracy': np.float64(0.9209676779645876)}, '687': {'predicted_x': [331.6157021337784, 352.2747399706244, 310.7851184127149, 305.86832101316605, 308.9459633383473, 347.37128695821525, 308.5549875113954, 308.29088541652413, 309.16993887156525, 307.2780311526805, 340.4325173028639, 307.81181941530343, 304.05488264414936, 335.351822270166, 324.6183046843133, 349.71850399647985, 290.9683580446071, 310.66851268065057, 308.58392295196506, 344.1025876892196, 309.407802093242], 'predicted_y': [534.2318111770921, 581.4664366350726, 523.8746602634525, 561.8958266841043, 551.3291577075722, 577.0637848835393, 516.949412002226, 548.1948303321756, 518.3948080756641, 548.4257781040928, 356.9659923682083, 528.1028986826549, 531.4063984840158, 366.5223117570684, 536.4707411287891, 314.2393787309171, 379.35216154871114, 523.6806467367983, 539.0290957036975, 578.4972503424387, 507.2918353882676], 'PrecisionSD': np.float64(1.5689833745617696), 'Accuracy': np.float64(1.5812318470276747)}}, '327': {'687': {'predicted_x': [306.3149625364491, 307.7119994062162, 306.8578476474672, 308.09092570142195, 305.0542009083315, 288.61137899890457, 306.0869241231975, 115.66857437604924, 306.8822182722232, 308.20156455077813, 309.10208329728493, 304.9241739791014, 300.2203907986261, 309.2849423485875, 308.63148314274827, 305.5980663525331, 308.8462916079626, 306.17652319251545, 307.4246628897247], 'predicted_y': [564.8444641385448, 545.4112882501367, 561.724259612831, 561.839945090425, 560.1161520322496, 327.3340571591273, 556.2615106259267, 389.4689230855575, 555.4195207385302, 554.0367499008049, 542.6133316397026, 557.4553319768172, 565.4465454165905, 562.3152134698393, 561.9247256875567, 560.2130775938583, 548.5833108160795, 561.023965636806, 550.3977200981676], 'PrecisionSD': np.float64(1.3125964214623211), 'Accuracy': np.float64(0.7521283630442832)}, '393': {'predicted_x': [313.0588992076191, 313.0503158280344, 314.116202569312, 312.2863026575237, 310.7658568245763, 315.7852924441652, 312.51045770406495, 312.91592740722825, 313.7493996536439, 315.1503380205652, 310.5397672678875, 312.2289644296475, 313.7197126504475, 315.12469495257733], 'predicted_y': [476.845948356213, 478.7756258302323, 528.3027870951792, 487.14044637944136, 481.041651076008, 536.4921355534882, 474.76630127281106, 420.42181243314195, 489.5718522414301, 475.18165249679697, 641.9415872401177, 479.89335456110194, 474.76234681741863, 476.0744190935473], 'PrecisionSD': np.float64(0.9298465277672457), 'Accuracy': np.float64(0.3766178528328967)}, '100': {'predicted_x': [393.623197328886, 344.59272308834574, 340.40901403581984, 387.8224496127286, 364.3312267131357, 367.97184717724144, 412.90314669058546, 368.3180982143326, 404.74390110485785, 390.3731651311229, 381.5373041924399, 391.12471733725613], 'predicted_y': [130.254607684346, 311.6674045220419, 330.53479864460047, 164.41131456116756, 212.85678234078313, 204.85212576628481, 146.18641591757398, 202.40997398979442, 156.33977865610933, 139.9743197329115, 149.3279292159787, 150.96498056336839], 'PrecisionSD': np.float64(0.5755444549472836), 'Accuracy': np.float64(0.46210638228300566)}}, '100': {'393': {'predicted_x': [310.8619739757677, 310.5025627854957, 307.51776037065906, 312.3414224114676, 310.34761312204023, 311.42830983153647, 311.00745809301395, 309.5169831409477, 309.86694961582083, 311.36472720182104, 309.5122528733552, 309.53609246264864, 310.29656351865987, 311.0639450817994, 308.8527738963366, 314.5140383105333, 309.84565949017815, 310.87788337397706, 309.39325344908076, 310.06213949497936, 309.67706558591453, 311.7231481773758], 'predicted_y': [377.8216156248154, 409.27224085931294, 394.33248033106537, 422.6192167262688, 431.0095787862502, 435.8926458193814, 485.7464849481569, 402.35642070827157, 496.8233389509555, 410.61096049597927, 503.62231158104726, 600.6863982048952, 414.90933992903683, 415.3643765156311, 596.4884944538417, 463.8955784242342, 426.9154295186968, 503.8773442206524, 432.6629203522524, 411.88650885880975, 430.7545325218591, 407.10833555748195], 'PrecisionSD': np.float64(0.9930498827592041), 'Accuracy': np.float64(1.0889467905031567)}, '687': {'predicted_x': [312.12841479854603, 321.70925776043543, 336.0127744988164, 317.9885647341873, 311.0310000718328, 364.2567578788239, 314.30598745133665, 352.531596042832, 311.63006505968735, 315.24215920456385, 313.31787107762915, 225.45049966860051, 312.79838579519947, 315.62474506177784, 315.9129984033359, 213.2327092346531], 'predicted_y': [534.2734756177654, 525.1470366516617, 342.2687646444054, 512.9098120063187, 557.69945195371, 306.0000479216859, 510.78479327307446, 297.80417482269974, 538.5168133665287, 455.5607918155015, 471.254763557045, 465.17673258654827, 528.7289470512834, 484.4262297058945, 442.6793480428661, 383.19479994382056], 'PrecisionSD': np.float64(1.059219644496741), 'Accuracy': np.float64(1.4493183672638663)}, '100': {'predicted_x': [349.15174931002844, 335.7499544253474, 351.89332233402877, 330.96514489280815, 305.21545618777367, 330.7319992495039, 342.62606244709184, 336.977565767249, 338.6556890408987, 335.08728452072495, 338.3320726057965, 325.3811104233329, 329.1195151928298, 347.6233468055878, 314.7708670573146, 330.693466110613, 322.4260568395586], 'predicted_y': [108.25626974116238, 81.60407967835414, 83.6523401932904, 111.77259791802891, 132.4067657764952, 189.15670490264205, 110.49589352303866, 10.33072944756833, 72.99641211021725, 25.638566879001758, 111.3369314245885, 112.99258831783271, 220.98843142910914, 98.79323534977715, 127.56856515906424, 187.5755599083198, 200.0990791780858], 'PrecisionSD': np.float64(0.4823898564008782), 'Accuracy': np.float64(0.9594639255922351)}}, 'centroids': [[367.1270959126717, 283.2966232241671], [312.669091239483, 551.8457480882452], [357.25368404288264, 134.12615028881297], [55.03325256039079, 456.048422959669], [357.7073786933521, -89.54847380297582], [118.61370614740667, -72.16070000618214], [309.92443568328696, 480.21729995863916], [309.64960646343343, 398.36695678489343], [501.1735176852717, 215.0229902240655]]},
'screen_height': 900, 'screen_width': 1440, 'k': 9}

def sanitize(obj):
if isinstance(obj, dict):
return {k: sanitize(v) for k, v in obj.items()}
if isinstance(obj, list):
return [sanitize(v) for v in obj]
if isinstance(obj, np.generic):
return obj.item()
return obj

clean_payload = sanitize(payload)

response = requests.post(
URL,
json=clean_payload,
headers={"Content-Type": "application/json"}
)

print("Status:", response.status_code)
print("Response:", response.text)