Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
from EasyOpticalCharacterRecognition import process_image
|
6 |
+
|
7 |
+
def infer(image):
|
8 |
+
img = np.array(image)
|
9 |
+
annotated_img, result_text = process_image(img)
|
10 |
+
return Image.fromarray(annotated_img), result_text
|
11 |
+
|
12 |
+
demo = gr.Interface(
|
13 |
+
fn=infer,
|
14 |
+
inputs=gr.Image(type="pil"),
|
15 |
+
outputs=[gr.Image(type="pil", label="Annotated Image"), gr.Textbox(label="Classification Results")],
|
16 |
+
title="Handwritten vs Computerized Text Detector",
|
17 |
+
description="Upload an image containing text. The system detects text using EasyOCR and classifies each as handwritten or computerized using MobileNet."
|
18 |
+
)
|
19 |
+
demo.launch()
|