Commit
·
1077963
1
Parent(s):
4f100b3
update ui
Browse files
app.py
CHANGED
|
@@ -235,24 +235,33 @@ with gr.Blocks() as demo:
|
|
| 235 |
"""<h1 style='text-align: center;'> PDFs to Page Images Converter</h1>
|
| 236 |
<center><i> 📁 Convert PDFs to an image dataset, splitting pages into individual images 📁 </i></center>"""
|
| 237 |
)
|
| 238 |
-
gr.
|
| 239 |
"""
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
"""
|
| 247 |
)
|
| 248 |
|
| 249 |
-
with gr.Row():
|
| 250 |
-
gr.LoginButton(size="sm")
|
| 251 |
-
|
| 252 |
with gr.Row():
|
| 253 |
pdf_files = gr.File(
|
| 254 |
file_count="multiple", label="Upload PDF(s)", file_types=["*.pdf"]
|
| 255 |
)
|
|
|
|
| 256 |
with gr.Row():
|
| 257 |
sample_percentage = gr.Slider(
|
| 258 |
minimum=0,
|
|
@@ -262,16 +271,21 @@ with gr.Blocks() as demo:
|
|
| 262 |
label="Percentage of pages to sample per PDF",
|
| 263 |
info="0% for no sampling (all pages), 100% for all pages",
|
| 264 |
)
|
| 265 |
-
hf_repo = gr.Textbox(
|
| 266 |
-
label="Hugging Face Repo",
|
| 267 |
-
placeholder="username/repo-name",
|
| 268 |
-
info="Enter the Hugging Face repository name in the format 'username/repo-name'",
|
| 269 |
-
)
|
| 270 |
-
with gr.Row():
|
| 271 |
create_zip = gr.Checkbox(label="Create ZIP file of images?", value=False)
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
with gr.Accordion("View converted images", open=False):
|
| 274 |
output_gallery = gr.Gallery(label="Converted Images")
|
|
|
|
| 275 |
status_text = gr.Markdown(label="Status")
|
| 276 |
download_button = gr.File(label="Download Converted Images")
|
| 277 |
|
|
|
|
| 235 |
"""<h1 style='text-align: center;'> PDFs to Page Images Converter</h1>
|
| 236 |
<center><i> 📁 Convert PDFs to an image dataset, splitting pages into individual images 📁 </i></center>"""
|
| 237 |
)
|
| 238 |
+
gr.HTML(
|
| 239 |
"""
|
| 240 |
+
<div style="display: flex; justify-content: center; align-items: center; max-width: 1000px; margin: 0 auto;">
|
| 241 |
+
<div style="flex: 1; padding-right: 20px;">
|
| 242 |
+
<p>This app allows you to:</p>
|
| 243 |
+
<ol>
|
| 244 |
+
<li>Upload one or more PDF files</li>
|
| 245 |
+
<li>Convert each page of the PDFs into separate image files</li>
|
| 246 |
+
<li>(Optionally) sample a specific number of pages from each PDF</li>
|
| 247 |
+
<li>(Optionally) Create a downloadable ZIP file of the converted images</li>
|
| 248 |
+
<li>(Optionally) Upload the images to a Hugging Face dataset repository</li>
|
| 249 |
+
</ol>
|
| 250 |
+
</div>
|
| 251 |
+
<div style="flex: 1;">
|
| 252 |
+
<img src="https://huggingface.co/spaces/Dataset-Creation-Tools/pdf-to-page-images-dataset/resolve/main/assets/PDF%20page%20split%20illustration.png"
|
| 253 |
+
alt="PDF page split illustration"
|
| 254 |
+
style="max-width: 50%; height: auto;">
|
| 255 |
+
</div>
|
| 256 |
+
</div>
|
| 257 |
"""
|
| 258 |
)
|
| 259 |
|
|
|
|
|
|
|
|
|
|
| 260 |
with gr.Row():
|
| 261 |
pdf_files = gr.File(
|
| 262 |
file_count="multiple", label="Upload PDF(s)", file_types=["*.pdf"]
|
| 263 |
)
|
| 264 |
+
|
| 265 |
with gr.Row():
|
| 266 |
sample_percentage = gr.Slider(
|
| 267 |
minimum=0,
|
|
|
|
| 271 |
label="Percentage of pages to sample per PDF",
|
| 272 |
info="0% for no sampling (all pages), 100% for all pages",
|
| 273 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
create_zip = gr.Checkbox(label="Create ZIP file of images?", value=False)
|
| 275 |
+
|
| 276 |
+
with gr.Accordion("Hugging Face Upload Options", open=True):
|
| 277 |
+
gr.LoginButton(size="sm")
|
| 278 |
+
with gr.Row():
|
| 279 |
+
hf_repo = gr.Textbox(
|
| 280 |
+
label="Hugging Face Repo",
|
| 281 |
+
placeholder="username/repo-name",
|
| 282 |
+
info="Enter the Hugging Face repository name in the format 'username/repo-name'",
|
| 283 |
+
)
|
| 284 |
+
private_repo = gr.Checkbox(label="Make repository private?", value=False)
|
| 285 |
+
|
| 286 |
with gr.Accordion("View converted images", open=False):
|
| 287 |
output_gallery = gr.Gallery(label="Converted Images")
|
| 288 |
+
|
| 289 |
status_text = gr.Markdown(label="Status")
|
| 290 |
download_button = gr.File(label="Download Converted Images")
|
| 291 |
|