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()