Spaces:
Runtime error
Runtime error
Create requests.py
Browse files- requests.py +20 -0
requests.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
# Define the URL of your deployed model endpoint
|
4 |
+
url = 'http://your-deployed-model-url/predict'
|
5 |
+
|
6 |
+
# Sample input data (replace this with your actual data)
|
7 |
+
data = {
|
8 |
+
'data': [[5.1, 3.5, 1.4, 0.2], [6.3, 2.9, 5.6, 1.8]]
|
9 |
+
}
|
10 |
+
|
11 |
+
# Send POST request to the deployed model endpoint
|
12 |
+
response = requests.post(url, json=data)
|
13 |
+
|
14 |
+
# Check if request was successful
|
15 |
+
if response.status_code == 200:
|
16 |
+
# Extract predictions from response
|
17 |
+
predictions = response.json()['predictions']
|
18 |
+
print("Predictions:", predictions)
|
19 |
+
else:
|
20 |
+
print("Error:", response.text)
|