Spaces:
Runtime error
Runtime error
api endpoint example
Browse files- api_example.py +11 -0
- cropped.jpg +0 -0
api_example.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
img_encode = gr.processing_utils.encode_url_or_file_to_base64("cropped.jpg")
|
5 |
+
|
6 |
+
r = requests.post(
|
7 |
+
url="https://hf.space/embed/AlexLach/LeakDetection/+/api/predict",
|
8 |
+
json={"data": [img_encode]},
|
9 |
+
)
|
10 |
+
print(r.json()["data"][0]["confidences"][0]["label"])
|
11 |
+
print(r.json()["data"][0]["confidences"][0]["confidence"])
|
cropped.jpg
ADDED