Spaces:
Build error
Build error
File size: 626 Bytes
4dbe5d1 |
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 |
import gradio as gr
import numpy as np
import cv2
from pathlib import Path
from main import RapidOCR
ocr_engine = RapidOCR()
def extract_text_from_bottom(image: np.ndarray):
h = image.shape[0]
# bottom_crop = image[int(h * 0.7):, :]
result, _ = ocr_engine(image, use_det=True, use_cls=False, use_rec=True)
if not result:
return "No text found."
texts = [r[1] for r in result]
return "\n".join(texts)
demo = gr.Interface(
fn=extract_text_from_bottom,
inputs=gr.Image(type="numpy"),
outputs="text",
title="",
description="",
)
demo.launch()
|