Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,18 @@ import json
|
|
6 |
import gradio as gr
|
7 |
|
8 |
# Define a function to call the API and get the results
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
threshold=0.5
|
11 |
# Convert the image to base64 string
|
12 |
with io.BytesIO() as output:
|
@@ -17,7 +28,7 @@ def get_results(imag):
|
|
17 |
payload = json.dumps({"base64str": base64str, "threshold": threshold})
|
18 |
|
19 |
# Send the request to the API
|
20 |
-
response = requests.put(
|
21 |
|
22 |
# Parse the JSON response
|
23 |
data = response.json()
|
|
|
6 |
import gradio as gr
|
7 |
|
8 |
# Define a function to call the API and get the results
|
9 |
+
import os
|
10 |
+
|
11 |
+
# Accessing a specific environment variable
|
12 |
+
api_key = os.environ.get('PXiVision')
|
13 |
+
|
14 |
+
# Checking if an environment variable exists
|
15 |
+
if 'PXiVision' in os.environ:
|
16 |
+
api_key = os.environ['PXiVision']
|
17 |
+
else:
|
18 |
+
print("API_KEY environment variable is not set.")
|
19 |
+
|
20 |
+
def get_results(image):
|
21 |
threshold=0.5
|
22 |
# Convert the image to base64 string
|
23 |
with io.BytesIO() as output:
|
|
|
28 |
payload = json.dumps({"base64str": base64str, "threshold": threshold})
|
29 |
|
30 |
# Send the request to the API
|
31 |
+
response = requests.put(api_key, data=payload)
|
32 |
|
33 |
# Parse the JSON response
|
34 |
data = response.json()
|