Spaces:
Runtime error
Runtime error
File size: 787 Bytes
9dc8196 6488435 2ea84fe 6488435 9dc8196 6488435 65df68c 6488435 65df68c 6488435 65df68c 6488435 2ea84fe 6488435 9dc8196 2ea84fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import numpy as np
import json
import gradio as gr
import easyocr
def index(image_url):
reader = easyocr.Reader(['en'])
result = reader.readtext(image_url)
texts = []
# probs = []
for (bbox, text, prob) in result:
# print(f'Text: {text}, Probability: {prob}')
texts.append(text)
# probs.append(prob)
output_dict = {"texts": texts}
output_json = json.dumps(output_dict)
return output_json
inputs_image_url = [
gr.Textbox(type="text", label="Image URL"),
]
outputs_result_json = [
gr.Textbox(type="text", label="Result JSON"),
]
interface_image_url = gr.Interface(
fn=index,
inputs=inputs_image_url,
outputs=outputs_result_json,
title="Text Extraction",
cache_examples=False,
).queue().launch()
|