binoua commited on
Commit
a288dbb
1 Parent(s): c0f39aa

chore: instance in europe

Browse files
Files changed (1) hide show
  1. play_with_endpoint.py +6 -3
play_with_endpoint.py CHANGED
@@ -20,8 +20,7 @@ def from_json(python_object):
20
  return bytes(python_object["__value__"])
21
 
22
 
23
- # TODO: put the right link `API_URL` for your entry point
24
- API_URL = "https://yw1dgyuig6ff5pft.us-east-1.aws.endpoints.huggingface.cloud"
25
  headers = {
26
  "Authorization": "Bearer " + os.environ.get("HF_TOKEN"),
27
  "Content-Type": "application/json",
@@ -86,8 +85,10 @@ for i in range(nb_samples):
86
 
87
  # Run the inference on HF servers
88
  duration -= time.time()
 
89
  encrypted_prediction = query(payload)
90
  duration += time.time()
 
91
 
92
  encrypted_prediction = from_json(encrypted_prediction)
93
 
@@ -96,7 +97,9 @@ for i in range(nb_samples):
96
  prediction = np.argmax(prediction_proba)
97
 
98
  if verbose or True:
99
- print(f"for {i}-th input, {prediction=} with expected {Y_test[i]}")
 
 
100
 
101
  # Measure accuracy
102
  nb_good += Y_test[i] == prediction
 
20
  return bytes(python_object["__value__"])
21
 
22
 
23
+ API_URL = "https://h0cvbig1fkmf57eb.eu-west-1.aws.endpoints.huggingface.cloud"
 
24
  headers = {
25
  "Authorization": "Bearer " + os.environ.get("HF_TOKEN"),
26
  "Content-Type": "application/json",
 
85
 
86
  # Run the inference on HF servers
87
  duration -= time.time()
88
+ duration_inference = -time.time()
89
  encrypted_prediction = query(payload)
90
  duration += time.time()
91
+ duration_inference += time.time()
92
 
93
  encrypted_prediction = from_json(encrypted_prediction)
94
 
 
97
  prediction = np.argmax(prediction_proba)
98
 
99
  if verbose or True:
100
+ print(
101
+ f"for {i}-th input, {prediction=} with expected {Y_test[i]} in {duration_inference} seconds"
102
+ )
103
 
104
  # Measure accuracy
105
  nb_good += Y_test[i] == prediction