k9lab commited on
Commit
b328b8d
·
verified ·
1 Parent(s): 07acff3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_client import Client, handle_file
3
+
4
+ def generate(file, num_page):
5
+ path_file = file.name if not isinstance(file, str) else file
6
+
7
+ client = Client("k9lab/p_pdf_to_text")
8
+ result = client.predict(
9
+ file_name=handle_file(path_file),
10
+ num_page=num_page,
11
+ api_name="/predict"
12
+ )
13
+ return result
14
+
15
+ iface = gr.Interface(
16
+ fn=generate,
17
+ inputs=[
18
+ gr.File(label="Sube tu archivo PDF"),
19
+ gr.Number(label="Número de páginas", value=5)
20
+ ],
21
+ outputs=[gr.Markdown(), gr.File()],
22
+ title="Convertidor de PDF a texto",
23
+ description="Sube un archivo PDF y especifica el número de página que deseas convertir a texto."
24
+ )
25
+
26
+ iface.launch()