|
a |
|
b/internal/prediction_client.py |
|
|
1 |
import requests |
|
|
2 |
|
|
|
3 |
HOST = 'localhost' |
|
|
4 |
PORT = '8420' |
|
|
5 |
def predict_http_request(payload): |
|
|
6 |
""" |
|
|
7 |
Args: |
|
|
8 |
- payload: {'array': (1, 10, 50) shape (10 frames)} |
|
|
9 |
Returns: |
|
|
10 |
- score: Value between 0 and 1 |
|
|
11 |
- status: Good or bad posture (depending on threshold:0.7) |
|
|
12 |
""" |
|
|
13 |
response = requests.post(f"http://{HOST}:{PORT}/predict", json=payload) |
|
|
14 |
if response.status_code == 200: |
|
|
15 |
return response.json() |
|
|
16 |
else: |
|
|
17 |
print("Error:", response.status_code) |
|
|
18 |
print(response.text) |