Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,21 +4,19 @@ import cv2
|
|
4 |
import requests
|
5 |
import 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
|
15 |
-
if
|
16 |
-
|
17 |
-
|
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:
|
24 |
image.save(output, format="JPEG")
|
@@ -47,7 +45,7 @@ def get_results(image):
|
|
47 |
|
48 |
# Define the input and output components for Gradio
|
49 |
image_input = gr.inputs.Image() # Adjust the shape according to your requirements
|
50 |
-
output_component = gr.outputs.Label(
|
51 |
|
52 |
# Launch the Gradio interface
|
53 |
-
gr.Interface(fn=get_results, inputs=image_input, outputs=output_component).launch()
|
|
|
4 |
import requests
|
5 |
import json
|
6 |
import gradio as gr
|
|
|
|
|
7 |
import os
|
8 |
|
9 |
# Accessing a specific environment variable
|
10 |
api_key = os.environ.get('PXiVision')
|
11 |
|
12 |
+
# Checking if the environment variable exists
|
13 |
+
if not api_key:
|
14 |
+
print("PXiVision environment variable is not set.")
|
15 |
+
exit()
|
|
|
16 |
|
17 |
+
# Define a function to call the API and get the results
|
18 |
def get_results(image):
|
19 |
+
threshold = 0.5
|
20 |
# Convert the image to base64 string
|
21 |
with io.BytesIO() as output:
|
22 |
image.save(output, format="JPEG")
|
|
|
45 |
|
46 |
# Define the input and output components for Gradio
|
47 |
image_input = gr.inputs.Image() # Adjust the shape according to your requirements
|
48 |
+
output_component = gr.outputs.Label()
|
49 |
|
50 |
# Launch the Gradio interface
|
51 |
+
gr.Interface(fn=get_results, inputs=image_input, outputs=output_component).launch()
|