Danieldu
commited on
Commit
•
c883606
1
Parent(s):
5e7197d
update .gitignore
Browse files- .gitignore +32 -0
- app.py +37 -10
- ppocr/utils/e2e_utils/__pycache__/extract_textpoint_fast.cpython-310.pyc +0 -0
- ppocr/utils/e2e_utils/__pycache__/extract_textpoint_slow.cpython-310.pyc +0 -0
- ppocr/utils/e2e_utils/__pycache__/pgnet_pp_utils.cpython-310.pyc +0 -0
- tools/infer/__pycache__/predict_cls.cpython-310.pyc +0 -0
- tools/infer/__pycache__/predict_det.cpython-310.pyc +0 -0
- tools/infer/__pycache__/predict_rec.cpython-310.pyc +0 -0
- tools/infer/__pycache__/predict_system.cpython-310.pyc +0 -0
- tools/infer/__pycache__/utility.cpython-310.pyc +0 -0
.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ppocr/data/__pycache__
|
2 |
+
ppocr/data/imaug/__pycache__
|
3 |
+
ppocr/data/imaug/text_image_aug/__pycache__
|
4 |
+
ppocr/data/imaug/vqa/__pycache__
|
5 |
+
ppocr/data/imaug/vqa/token/__pycache__
|
6 |
+
ppocr/modeling/backbones/__pycache__
|
7 |
+
ppocr/modeling/heads/__pycache__
|
8 |
+
ppocr/modeling/necks/__pycache__
|
9 |
+
ppocr/modeling/transforms/__pycache__
|
10 |
+
ppocr/modeling/postprocess/__pycache__
|
11 |
+
ppocr/modeling/postprocess/utils/__pycache__
|
12 |
+
ppocr/modeling/postprocess/utils/e2e_metric/__pycache__
|
13 |
+
ppocr/modeling/postprocess/utils/e2e_utils/__pycache__
|
14 |
+
ppocr/modeling/postprocess/utils/loggers/__pycache__
|
15 |
+
ppstructure/__pycache__
|
16 |
+
ppstructure/kie/__pycache__
|
17 |
+
ppstructure/layout/__pycache__
|
18 |
+
ppstructure/table/__pycache__
|
19 |
+
tools/__pycache__
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
app.py
CHANGED
@@ -38,18 +38,45 @@ def inference__ppstructure(img_path):
|
|
38 |
rec_image_shape="3, 48, 320",
|
39 |
ser_dict_path='ppocr/utils/dict/kie/clinical_class_list.txt'
|
40 |
)
|
|
|
|
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
image = draw_ser_results(img_path,result,font_path='./simfang.ttf')
|
44 |
result = [''.join(f"{element['pred']}:{element['transcription']}") for element in result if element['pred']!='O']
|
45 |
return image, "\n".join(result)
|
46 |
|
47 |
-
|
48 |
-
gr.
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
rec_image_shape="3, 48, 320",
|
39 |
ser_dict_path='ppocr/utils/dict/kie/clinical_class_list.txt'
|
40 |
)
|
41 |
+
samples = ['病歷','身份','姓名',' Medical','No.','Name','性別','中華民國','002480','身分','Attending','M.D','ID','Medical','by','續上頁診斷書內容','出生地','列印時間','以上','年齡','特予']
|
42 |
+
result,_ = ppsutructure.__call__(img_path)
|
43 |
|
44 |
+
for element in result:
|
45 |
+
for sample in samples:
|
46 |
+
if sample in element['transcription']:
|
47 |
+
element['pred_id'] = 0
|
48 |
+
element['pred'] ='O'
|
49 |
image = draw_ser_results(img_path,result,font_path='./simfang.ttf')
|
50 |
result = [''.join(f"{element['pred']}:{element['transcription']}") for element in result if element['pred']!='O']
|
51 |
return image, "\n".join(result)
|
52 |
|
53 |
+
with gr.Blocks() as demo:
|
54 |
+
gr.Markdown("Form Understanding Project - Certificate of Diagnosis")
|
55 |
+
gr.Markdown("Support languages:traditinonal chinese")
|
56 |
+
gr.Markdown("""
|
57 |
+
## Usage Description
|
58 |
+
This interface is designed to process and extract information from Certificates of Diagnosis.
|
59 |
+
To use this tool:
|
60 |
+
1. Upload an image of a Certificate of Diagnosis using the 'Upload Image' button.
|
61 |
+
2. Optionally, enter the image URL if the certificate is available online.
|
62 |
+
3. Click 'Process' to extract information from the uploaded certificate.
|
63 |
+
4. The processed image and extracted text will be displayed on the right.
|
64 |
+
""")
|
65 |
+
with gr.Row():
|
66 |
+
with gr.Column():
|
67 |
+
image_input = gr.Image(type='filepath', label='Upload Image')
|
68 |
+
url_input = gr.Textbox(label='Or enter Image URL')
|
69 |
+
submit_btn = gr.Button("Process")
|
70 |
+
with gr.Column():
|
71 |
+
gr.Markdown("#### Processed Image")
|
72 |
+
image_output = gr.Image(type="pil", label="Processed Image")
|
73 |
+
gr.Markdown("#### Extracted Text")
|
74 |
+
text_output = gr.Textbox(label="Extracted Text")
|
75 |
+
|
76 |
+
submit_btn.click(
|
77 |
+
inference__ppstructure,
|
78 |
+
inputs=[image_input],
|
79 |
+
outputs=[image_output, text_output]
|
80 |
+
)
|
81 |
+
|
82 |
+
demo.launch(debug=True)
|
ppocr/utils/e2e_utils/__pycache__/extract_textpoint_fast.cpython-310.pyc
DELETED
Binary file (12.9 kB)
|
|
ppocr/utils/e2e_utils/__pycache__/extract_textpoint_slow.cpython-310.pyc
DELETED
Binary file (13.6 kB)
|
|
ppocr/utils/e2e_utils/__pycache__/pgnet_pp_utils.cpython-310.pyc
DELETED
Binary file (3.93 kB)
|
|
tools/infer/__pycache__/predict_cls.cpython-310.pyc
DELETED
Binary file (4.1 kB)
|
|
tools/infer/__pycache__/predict_det.cpython-310.pyc
DELETED
Binary file (8.55 kB)
|
|
tools/infer/__pycache__/predict_rec.cpython-310.pyc
DELETED
Binary file (13.7 kB)
|
|
tools/infer/__pycache__/predict_system.cpython-310.pyc
DELETED
Binary file (7.11 kB)
|
|
tools/infer/__pycache__/utility.cpython-310.pyc
DELETED
Binary file (17.3 kB)
|
|