Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,24 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import pytesseract
|
3 |
-
from pdf2image import convert_from_path
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
# Extraer texto de cada p谩gina
|
10 |
-
text_data = ''
|
11 |
-
for page in pages:
|
12 |
-
text = pytesseract.image_to_string(page)
|
13 |
-
text_data += text + '\n'
|
14 |
-
|
15 |
-
return text_data
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
iface = gr.Interface(
|
19 |
-
fn=
|
20 |
-
inputs=gr.
|
21 |
-
outputs="
|
22 |
-
title="
|
23 |
-
description="Sube
|
24 |
)
|
25 |
|
26 |
-
#
|
27 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
import pytesseract
|
|
|
4 |
|
5 |
+
# Aseg煤rate de que el ejecutable de Tesseract est茅 en tu PATH
|
6 |
+
# o especifica la ruta completa
|
7 |
+
# pytesseract.pytesseract.tesseract_cmd = r'<ruta_completa_a_tesseract>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
def ocr_image(image):
|
10 |
+
# Convierte la imagen a texto usando pytesseract
|
11 |
+
text = pytesseract.image_to_string(image)
|
12 |
+
return text
|
13 |
+
|
14 |
+
# Crea la interfaz de Gradio
|
15 |
iface = gr.Interface(
|
16 |
+
fn=ocr_image, # Funci贸n que procesa la imagen
|
17 |
+
inputs=gr.Image(type="pil", label="Sube tu imagen"), # Tipo de entrada: imagen
|
18 |
+
outputs=gr.Textbox(label="Texto extra铆do"), # Tipo de salida: texto
|
19 |
+
title="OCR con Python Tesseract",
|
20 |
+
description="Sube una imagen para extraer el texto usando Tesseract OCR."
|
21 |
)
|
22 |
|
23 |
+
# Ejecuta la interfaz
|
24 |
iface.launch()
|