import gradio as gr import cv2 import numpy as np from PIL import Image from EasyOpticalCharacterRecognition import process_image # Wrapper function for Gradio interface def infer(image): img = np.array(image) annotated_img, result_text = process_image(img) return Image.fromarray(annotated_img), result_text # Custom CSS for light blue background and bordered elements custom_css = """ body { background-color: #e6f2ff; } .gradio-container { border-radius: 12px; padding: 20px; border: 2px solid #007acc; } .gr-input, .gr-output { border: 1px solid #007acc; border-radius: 10px; } """ # Gradio Interface demo = gr.Interface( fn=infer, inputs=gr.Image(type="pil", label="Upload Image"), outputs=[ gr.Image(type="pil", label="Annotated Image"), gr.Textbox(label="Detected Text and Classification") ], title="🧠 OCR & Text Type Classifier", description="Application detect text from images and classifier classify text into Computerized & Handwritten Text.", theme="soft", # Optional: you can also try "default" or "huggingface" css=custom_css ) demo.launch()