File size: 718 Bytes
85b1295
 
 
30dbf30
e69418b
 
6db03a3
85b1295
e69418b
 
 
 
 
5d5fa27
1ef5b91
a58dbb4
1ef5b91
7d155ba
4573347
29981ef
17e4c75
e69418b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
Run a rest API exposing the yolov5s object detection model
"""

import gradio as gr
import requests


def detect(inp):
    filename=inp
    bs64Data=gr.processing_utils.encode_file_to_base64(filename)
    r = requests.post(url='https://hf.space/gradioiframe/Sa-m/Political-Party-Symbol-Detector-V1/+/api/predict/',
                  json={"data": [bs64Data]})
    
    res= r.json()
    res['data']='hidden since it is a large base64 file'
    return res 
    
inp = gr.inputs.Image(type='filepath', label="Input Image")
output=gr.outputs.JSON(label='Response')
io=gr.Interface(fn=detect, inputs=inp, outputs=output, title='Party Symbol Detector API',examples=['8.jpg','24.jpg'])
io.launch(debug=True,share=False)