sayedM commited on
Commit
bdf434b
·
1 Parent(s): daba3dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
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 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:
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(num_top_classes=len(output_labels))
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()