AlexLach commited on
Commit
5458da7
·
1 Parent(s): c7381a9

api endpoint example

Browse files
Files changed (2) hide show
  1. api_example.py +11 -0
  2. 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