File size: 1,060 Bytes
7ee7e3a
62ce180
7ee7e3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3bd70f6
7ee7e3a
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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()