Michal Tichý
x
22777c4
import gradio as gr
from utils import PingApi
def inference(img):
papi = PingApi()
rsp = papi.ping_api(img, 'vin-mining')
if len(rsp['pages']) == 0:
return {'no data to extract': 0}
gathered_data = rsp['pages'][0]['gathered_data']
parsed_rsp = {
gathered_data['fields']['VIN']['texts'][0]['text']: gathered_data['fields']['VIN']['texts'][0]['confidence']
}
return parsed_rsp
title = "Car VIN mining"
description = "Extract VIN code of vehicle, if present in the image"
examples = [['./examples/ex1.jpg'], ['./examples/ex2.jpg'], ['./examples/ex3.jpg']]
gr.Interface(
inference,
inputs=gr.Image(type="filepath"),
outputs=[gr.Label(num_top_classes=1, label='Output')],
title=title,
description=description,
examples=examples
).launch()