Duy-NM
commited on
Commit
·
0174efb
1
Parent(s):
029ea56
add card visit
Browse files- .gitignore +1 -0
- app.py +22 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
*.pyc
|
app.py
CHANGED
@@ -6,6 +6,7 @@ from gradio_client import Client
|
|
6 |
token = os.environ['token']
|
7 |
client_cmt = Client("https://vtechai-ocr-cmt.hf.space/--replicas/crwgk/", token)
|
8 |
client_lic = Client("https://vtechai-ocr-license.hf.space/--replicas/cppkz/", token)
|
|
|
9 |
|
10 |
|
11 |
def ocr_cmt(img1, img2):
|
@@ -36,6 +37,13 @@ def ocr_regi(img):
|
|
36 |
|
37 |
return result
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
with gr.Blocks() as idcard_bl:
|
41 |
with gr.Row():
|
@@ -82,6 +90,20 @@ with gr.Blocks() as register_bl:
|
|
82 |
|
83 |
btn.click(fn=ocr_regi, inputs=[im1], outputs=[js])
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
with gr.Blocks() as demo:
|
86 |
gr.Markdown('<h1 style="text-align: center;">V-Reader</h1>')
|
87 |
gr.Markdown("*Chọn chức năng bạn muốn trải nghiệm")
|
|
|
6 |
token = os.environ['token']
|
7 |
client_cmt = Client("https://vtechai-ocr-cmt.hf.space/--replicas/crwgk/", token)
|
8 |
client_lic = Client("https://vtechai-ocr-license.hf.space/--replicas/cppkz/", token)
|
9 |
+
client_vis = Client("https://vtechai-ocr-cardvisit.hf.space/--replicas/dqpl5/", token)
|
10 |
|
11 |
|
12 |
def ocr_cmt(img1, img2):
|
|
|
37 |
|
38 |
return result
|
39 |
|
40 |
+
def ocr_vis(img, lang):
|
41 |
+
js = client_vis.predict(img, lang, fn_index=1)
|
42 |
+
with open(js) as f:
|
43 |
+
result = json.load(f)
|
44 |
+
|
45 |
+
return result
|
46 |
+
|
47 |
|
48 |
with gr.Blocks() as idcard_bl:
|
49 |
with gr.Row():
|
|
|
90 |
|
91 |
btn.click(fn=ocr_regi, inputs=[im1], outputs=[js])
|
92 |
|
93 |
+
with gr.Blocks() as cardvisit_lb:
|
94 |
+
with gr.Row():
|
95 |
+
with gr.Column():
|
96 |
+
im1 = gr.Image(height=500, type='filepath', container=True)
|
97 |
+
lang = gr.Radio(["vi", "en", "ja"], label="Language", value="vi")
|
98 |
+
|
99 |
+
with gr.Column():
|
100 |
+
js = gr.JSON(label="json")
|
101 |
+
|
102 |
+
with gr.Row():
|
103 |
+
btn = gr.Button(value="Run")
|
104 |
+
btn_clean = gr.ClearButton([im1, lang, js])
|
105 |
+
btn.click(fn=ocr_vis, inputs=[im1, lang], outputs=[js])
|
106 |
+
|
107 |
with gr.Blocks() as demo:
|
108 |
gr.Markdown('<h1 style="text-align: center;">V-Reader</h1>')
|
109 |
gr.Markdown("*Chọn chức năng bạn muốn trải nghiệm")
|