Spaces:
Runtime error
Runtime error
| 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() | |