Spaces:
Sleeping
Sleeping
v4
Browse files
app.py
CHANGED
@@ -20,13 +20,14 @@ def predict(image):
|
|
20 |
response = {"message": "Detection successful!"}
|
21 |
return response
|
22 |
|
23 |
-
# Create a
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
interface.launch()
|
32 |
|
|
|
|
|
|
20 |
response = {"message": "Detection successful!"}
|
21 |
return response
|
22 |
|
23 |
+
# Create a Gradio interface and enable the API mode
|
24 |
+
interface = gr.Interface(
|
25 |
+
fn=predict,
|
26 |
+
inputs="image",
|
27 |
+
outputs="json",
|
28 |
+
allow_flagging="never",
|
29 |
+
live=True # Allows the API endpoint to remain active
|
30 |
+
)
|
|
|
31 |
|
32 |
+
# Launch the interface with API mode enabled
|
33 |
+
interface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
test.py
CHANGED
@@ -3,7 +3,7 @@ import json
|
|
3 |
|
4 |
# Replace with your actual Space URL
|
5 |
API_URL = "https://shorndrup-owlvit-api.hf.space/predict"
|
6 |
-
image_path =
|
7 |
|
8 |
with open(image_path, "rb") as image_file:
|
9 |
files = {"data": image_file}
|
@@ -13,9 +13,4 @@ with open(image_path, "rb") as image_file:
|
|
13 |
print(response.text)
|
14 |
|
15 |
# Try parsing JSON if the response is valid JSON
|
16 |
-
|
17 |
-
print(response.json())
|
18 |
-
except requests.exceptions.JSONDecodeError:
|
19 |
-
print("Response is not in JSON format")
|
20 |
-
print(f"Status Code: {response.status_code}")
|
21 |
-
print(response.headers)
|
|
|
3 |
|
4 |
# Replace with your actual Space URL
|
5 |
API_URL = "https://shorndrup-owlvit-api.hf.space/predict"
|
6 |
+
image_path = "C:/Users/Administrator/Downloads/pokedex/images/solrock.png"
|
7 |
|
8 |
with open(image_path, "rb") as image_file:
|
9 |
files = {"data": image_file}
|
|
|
13 |
print(response.text)
|
14 |
|
15 |
# Try parsing JSON if the response is valid JSON
|
16 |
+
print(response.json())
|
|
|
|
|
|
|
|
|
|