Alimustoofaa's picture
update app
1bff13d
import cv2
import numpy as np
import gradio as gr
from ocr import OCR
ocr = OCR()
def visualize_img(image, boxes):
for box in boxes:
points = np.array(box, dtype=np.int32).reshape((-1, 1, 2))
image = cv2.polylines(image, [points], True, (255, 0, 0), 1)
return image
def process_ocr(input_img):
result = ocr.ocr_image(input_img)
boxes, txts, scores = ocr.extract_output(result)
# Visualize image and boxes
image_drawed = visualize_img(input_img, boxes)
# Marger txts
text = ' '.join([i for i in txts])
return image_drawed, text
title = "OCR License Plate Indonesia"
css = ".image-preview {height: auto !important;}"
iface = gr.Interface(
title = title,
fn = process_ocr,
inputs = [gr.Image()],
outputs = [gr.Image(), 'text'],
css=css
)
iface.launch()