Spaces:
Running
Running
π¨
Browse filesSigned-off-by: peter szemraj <[email protected]>
app.py
CHANGED
|
@@ -55,7 +55,11 @@ def load_uploaded_file(file_obj, temp_dir: Path = None):
|
|
| 55 |
return None
|
| 56 |
|
| 57 |
|
| 58 |
-
def convert_PDF(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
"""
|
| 60 |
convert_PDF - convert a PDF file to text
|
| 61 |
|
|
@@ -125,7 +129,9 @@ if __name__ == "__main__":
|
|
| 125 |
with demo:
|
| 126 |
|
| 127 |
gr.Markdown("# PDF to Text")
|
| 128 |
-
gr.Markdown(
|
|
|
|
|
|
|
| 129 |
gr.Markdown("---")
|
| 130 |
|
| 131 |
with gr.Column():
|
|
@@ -134,13 +140,12 @@ if __name__ == "__main__":
|
|
| 134 |
gr.Markdown("Upload your own file & replace the default")
|
| 135 |
gr.Markdown("_If no file is uploaded, a sample PDF will be used_")
|
| 136 |
|
| 137 |
-
|
| 138 |
uploaded_file = gr.File(
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
gr.Markdown("---")
|
| 146 |
|
|
@@ -160,6 +165,8 @@ if __name__ == "__main__":
|
|
| 160 |
)
|
| 161 |
|
| 162 |
convert_button.click(
|
| 163 |
-
fn=convert_PDF,
|
|
|
|
|
|
|
| 164 |
)
|
| 165 |
demo.launch(enable_queue=True)
|
|
|
|
| 55 |
return None
|
| 56 |
|
| 57 |
|
| 58 |
+
def convert_PDF(
|
| 59 |
+
pdf_obj,
|
| 60 |
+
language: str = "en",
|
| 61 |
+
max_pages=20,
|
| 62 |
+
):
|
| 63 |
"""
|
| 64 |
convert_PDF - convert a PDF file to text
|
| 65 |
|
|
|
|
| 129 |
with demo:
|
| 130 |
|
| 131 |
gr.Markdown("# PDF to Text")
|
| 132 |
+
gr.Markdown(
|
| 133 |
+
"A basic demo of pdf-to-text conversion using OCR from the [doctr](https://mindee.github.io/doctr/index.html) package"
|
| 134 |
+
)
|
| 135 |
gr.Markdown("---")
|
| 136 |
|
| 137 |
with gr.Column():
|
|
|
|
| 140 |
gr.Markdown("Upload your own file & replace the default")
|
| 141 |
gr.Markdown("_If no file is uploaded, a sample PDF will be used_")
|
| 142 |
|
|
|
|
| 143 |
uploaded_file = gr.File(
|
| 144 |
+
label="Upload a PDF file",
|
| 145 |
+
file_count="single",
|
| 146 |
+
type="file",
|
| 147 |
+
value=_here / "example_file.pdf",
|
| 148 |
+
)
|
| 149 |
|
| 150 |
gr.Markdown("---")
|
| 151 |
|
|
|
|
| 165 |
)
|
| 166 |
|
| 167 |
convert_button.click(
|
| 168 |
+
fn=convert_PDF,
|
| 169 |
+
inputs=[uploaded_file],
|
| 170 |
+
outputs=[OCR_text, out_placeholder, text_file],
|
| 171 |
)
|
| 172 |
demo.launch(enable_queue=True)
|