Spaces:
Runtime error
Runtime error
Commit
•
f970a37
1
Parent(s):
0833a56
Update app.py
Browse files
app.py
CHANGED
@@ -136,4 +136,44 @@ if __name__ == "__main__":
|
|
136 |
gr.Markdown(
|
137 |
"A basic demo for end-to-end text detection and recognition where the input will be in pdf format and the result is text conversion using OCR from the [doctr](https://mindee.github.io/doctr/index.html) package"
|
138 |
)
|
139 |
-
gr.Markdown("---")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
gr.Markdown(
|
137 |
"A basic demo for end-to-end text detection and recognition where the input will be in pdf format and the result is text conversion using OCR from the [doctr](https://mindee.github.io/doctr/index.html) package"
|
138 |
)
|
139 |
+
gr.Markdown("---")
|
140 |
+
gr.Markdown("---")
|
141 |
+
|
142 |
+
with gr.Column():
|
143 |
+
|
144 |
+
gr.Markdown("## Load Inputs")
|
145 |
+
gr.Markdown("Upload your own file & replace the default. Files should be < 10MB to avoid upload issues - search for a PDF compressor online as needed.")
|
146 |
+
gr.Markdown(
|
147 |
+
"_If no file is uploaded, a sample PDF will be used. PDFs are truncated to 20 pages._"
|
148 |
+
)
|
149 |
+
|
150 |
+
uploaded_file = gr.File(
|
151 |
+
label="Upload a PDF file",
|
152 |
+
file_count="single",
|
153 |
+
type="file",
|
154 |
+
value=_here / "example_file.pdf",
|
155 |
+
)
|
156 |
+
|
157 |
+
gr.Markdown("---")
|
158 |
+
|
159 |
+
with gr.Column():
|
160 |
+
gr.Markdown("## Convert PDF to Text")
|
161 |
+
convert_button = gr.Button("Convert PDF!", variant="primary")
|
162 |
+
out_placeholder = gr.HTML("<p><em>Output will appear below:</em></p>")
|
163 |
+
gr.Markdown("### Output")
|
164 |
+
OCR_text = gr.Textbox(
|
165 |
+
label="OCR Result", placeholder="The OCR text will appear here"
|
166 |
+
)
|
167 |
+
text_file = gr.File(
|
168 |
+
label="Download Text File",
|
169 |
+
file_count="single",
|
170 |
+
type="file",
|
171 |
+
interactive=False,
|
172 |
+
)
|
173 |
+
|
174 |
+
convert_button.click(
|
175 |
+
fn=convert_PDF,
|
176 |
+
inputs=[uploaded_file],
|
177 |
+
outputs=[OCR_text, out_placeholder, text_file],
|
178 |
+
)
|
179 |
+
demo.launch(enable_queue=True)
|