MMOCR_Infer / app.py
dinhquangson's picture
Update app.py
f095eaf
raw
history blame contribute delete
740 Bytes
import gradio as gr
import os
os.system('pip install -U openmim')
os.system('mim install mmengine')
os.system('mim install mmcv>=2.0.0rc1')
os.system('mim install mmdet>=3.0.0rc0')
os.system('git clone https://github.com/open-mmlab/mmcv.git')
os.system('cd mmcv')
os.system('MMCV_WITH_OPS=1 pip install -e .')
from mmocr.apis import MMOCRInferencer
import mmcv
infer = MMOCRInferencer(det='dbnetpp', rec='svtr-small', kie='SDMGR')
def inference(filename):
result = infer(filename, return_vis=True)
print(len(result['visualization']))
return result['predictions'],result['visualization'][0]
iface = gr.Interface(fn=inference, inputs=[gr.Image(type="filepath")], outputs=[gr.Textbox(),gr.Image(type="pil")])
iface.launch()