Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed May 4, 2018
1 parent 2812c3c commit 2bf6579
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/ai/src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from learn import AI

ai_cache = ExpiringDict(max_len=100000,max_age_seconds=60)
ai_cache = ExpiringDict(max_len=100000, max_age_seconds=60)


def to_base58(family):
Expand All @@ -46,7 +46,8 @@ def classify():
if 'data_folder' in payload:
data_folder = payload['data_folder']

fname = os.path.join(data_folder, to_base58(payload['sensor_data']['f']) + ".find3.ai")
fname = os.path.join(data_folder, to_base58(
payload['sensor_data']['f']) + ".find3.ai")

ai = ai_cache.get(payload['sensor_data']['f'])
if ai == None:
Expand All @@ -60,7 +61,8 @@ def classify():

classified = ai.classify(payload['sensor_data'])

logger.debug("{:d} ms".format(int(1000 * (t - time.time()))))
logger.debug("classifed for {} {:d} ms".format(
payload['sensor_data']['f'], int(1000 * (t - time.time()))))
return jsonify({"success": True, "message": "data analyzed", 'analysis': classified})


Expand All @@ -87,7 +89,8 @@ def learn():
return jsonify({"success": False, "message": "could not find '{}'".format(fname)})

print(payload['family'])
ai.save(os.path.join(data_folder, to_base58(payload['family']) + ".find3.ai"))
ai.save(os.path.join(data_folder, to_base58(
payload['family']) + ".find3.ai"))
ai_cache[payload['family']] = ai
return jsonify({"success": True, "message": "calibrated data"})

Expand Down

0 comments on commit 2bf6579

Please sign in to comment.