DNIs Panama
Browse files- .gitignore +1 -0
- app.py +44 -15
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
/venv/
|
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import atexit
|
|
| 2 |
import functools
|
| 3 |
from queue import Queue
|
| 4 |
from threading import Event, Thread
|
|
|
|
| 5 |
|
| 6 |
from paddleocr import PaddleOCR, draw_ocr
|
| 7 |
from PIL import Image
|
|
@@ -90,6 +91,22 @@ atexit.register(close_model_managers)
|
|
| 90 |
def inference(img, lang):
|
| 91 |
ocr = model_managers[lang]
|
| 92 |
result = ocr.infer(img, cls=True)[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
img_path = img
|
| 94 |
image = Image.open(img_path).convert("RGB")
|
| 95 |
boxes = [line[0] for line in result]
|
|
@@ -97,21 +114,33 @@ def inference(img, lang):
|
|
| 97 |
scores = [line[1][1] for line in result]
|
| 98 |
im_show = draw_ocr(image, boxes, txts, scores,
|
| 99 |
font_path="./simfang.ttf")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
return im_show
|
| 101 |
|
| 102 |
|
| 103 |
-
title = 'PaddleOCR'
|
| 104 |
-
description = '''
|
| 105 |
-
- Gradio demo for PaddleOCR. PaddleOCR demo supports Chinese, English, French, German, Korean and Japanese.
|
| 106 |
-
- To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.
|
| 107 |
-
- [Docs](https://paddlepaddle.github.io/PaddleOCR/), [Github Repository](https://github.com/PaddlePaddle/PaddleOCR).
|
| 108 |
-
'''
|
| 109 |
|
| 110 |
-
examples = [
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
]
|
| 115 |
|
| 116 |
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
| 117 |
gr.Interface(
|
|
@@ -121,10 +150,10 @@ gr.Interface(
|
|
| 121 |
gr.Dropdown(choices=list(LANG_CONFIG.keys()), value='en', label='language')
|
| 122 |
],
|
| 123 |
gr.Image(type='pil', label='Output'),
|
| 124 |
-
title=title,
|
| 125 |
-
description=description,
|
| 126 |
-
examples=examples,
|
| 127 |
cache_examples=False,
|
| 128 |
css=css,
|
| 129 |
concurrency_limit=CONCURRENCY_LIMIT,
|
| 130 |
-
).launch(debug=False)
|
|
|
|
| 2 |
import functools
|
| 3 |
from queue import Queue
|
| 4 |
from threading import Event, Thread
|
| 5 |
+
import time
|
| 6 |
|
| 7 |
from paddleocr import PaddleOCR, draw_ocr
|
| 8 |
from PIL import Image
|
|
|
|
| 91 |
def inference(img, lang):
|
| 92 |
ocr = model_managers[lang]
|
| 93 |
result = ocr.infer(img, cls=True)[0]
|
| 94 |
+
|
| 95 |
+
print("Imprimiendo cada elemento de 'result' en un rengl贸n:")
|
| 96 |
+
for item in result:
|
| 97 |
+
print(item)
|
| 98 |
+
|
| 99 |
+
time.sleep(8)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
print("Resultado de la inferencia: ")
|
| 109 |
+
print(result)
|
| 110 |
img_path = img
|
| 111 |
image = Image.open(img_path).convert("RGB")
|
| 112 |
boxes = [line[0] for line in result]
|
|
|
|
| 114 |
scores = [line[1][1] for line in result]
|
| 115 |
im_show = draw_ocr(image, boxes, txts, scores,
|
| 116 |
font_path="./simfang.ttf")
|
| 117 |
+
print("Impresi贸n de todos los resultados: ")
|
| 118 |
+
print("Boxes:")
|
| 119 |
+
print(boxes)
|
| 120 |
+
print("Texts:")
|
| 121 |
+
print(txts)
|
| 122 |
+
print("Scores:")
|
| 123 |
+
print(scores)
|
| 124 |
+
|
| 125 |
+
print("Detecci贸n de Nombre:")
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
return im_show
|
| 130 |
|
| 131 |
|
| 132 |
+
# title = 'PaddleOCR'
|
| 133 |
+
# description = '''
|
| 134 |
+
# - Gradio demo for PaddleOCR. PaddleOCR demo supports Chinese, English, French, German, Korean and Japanese.
|
| 135 |
+
# - To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.
|
| 136 |
+
# - [Docs](https://paddlepaddle.github.io/PaddleOCR/), [Github Repository](https://github.com/PaddlePaddle/PaddleOCR).
|
| 137 |
+
# '''
|
| 138 |
|
| 139 |
+
# examples = [
|
| 140 |
+
# ['en_example.jpg','en'],
|
| 141 |
+
# ['cn_example.jpg','ch'],
|
| 142 |
+
# ['jp_example.jpg','japan'],
|
| 143 |
+
# ]
|
| 144 |
|
| 145 |
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
| 146 |
gr.Interface(
|
|
|
|
| 150 |
gr.Dropdown(choices=list(LANG_CONFIG.keys()), value='en', label='language')
|
| 151 |
],
|
| 152 |
gr.Image(type='pil', label='Output'),
|
| 153 |
+
#title=title,
|
| 154 |
+
#description=description,
|
| 155 |
+
#examples=examples,
|
| 156 |
cache_examples=False,
|
| 157 |
css=css,
|
| 158 |
concurrency_limit=CONCURRENCY_LIMIT,
|
| 159 |
+
).launch(debug=False)
|