Spaces:
Build error
Build error
import os | |
os.system('pip install --upgrade pip') | |
import string | |
import gradio as gr | |
from src.app.text_recognition import TextRecognition | |
root_path = os.path.expanduser('~/.Halotec/Models') | |
model_config = { | |
'filename' : 'crnn_008000.pt', | |
'classes' : string.digits+string.ascii_uppercase+'. ', | |
'url' : 'https://github.com/Alimustoofaa/Research-OCR-License-Plate/releases/download/crnn/crnn_008000.pt', | |
'file_size' : 31379595, | |
'img_height': 32, | |
'img_width' : 100, | |
'map_to_seq_hidden': 64, | |
'rnn_hidden': 256, | |
'leaky_relu': False | |
} | |
model_ocr = TextRecognition(root_path, model_config, jic=True) | |
def recognition(image): | |
result = model_ocr.recognition(image, decode='beam_search', beam_size=10) | |
txt, conf = result['text'], result['confidence'] | |
return txt, conf | |
title = "CRNN Container Number" | |
css = ".image-preview {height: auto !important;}" | |
iface = gr.Interface( | |
title = title, | |
fn = recognition, | |
inputs = [gr.Image()], | |
outputs = ['text', 'text'], | |
css=css | |
) | |
iface.launch() |