Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -513,43 +513,34 @@ def get_images_html():
|
|
| 513 |
# Create HTML for displaying images
|
| 514 |
html = "<div class='image-gallery'>"
|
| 515 |
|
| 516 |
-
if not
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
current_page = page_num
|
| 530 |
-
html += f"<h2 class='page-header'>Page {page_num}</h2>"
|
| 531 |
|
| 532 |
-
#
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
image_type = 'jpeg'
|
| 536 |
-
elif file_ext == '.png':
|
| 537 |
-
image_type = 'png'
|
| 538 |
-
else:
|
| 539 |
-
image_type = 'jpeg' # Default fallback
|
| 540 |
|
| 541 |
-
# In Hugging Face Spaces, files are directly accessible via the path
|
| 542 |
-
# Format the HTML to use the image directly from the space
|
| 543 |
html += f"""
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
</div>
|
| 552 |
</div>
|
|
|
|
| 553 |
"""
|
| 554 |
|
| 555 |
html += "</div>"
|
|
|
|
| 513 |
# Create HTML for displaying images
|
| 514 |
html = "<div class='image-gallery'>"
|
| 515 |
|
| 516 |
+
# The problem was that we were checking if image_files is empty, but it's not empty
|
| 517 |
+
# We have the list of files, we just need to display them
|
| 518 |
+
|
| 519 |
+
current_page = None
|
| 520 |
+
for image_file in image_files:
|
| 521 |
+
# Extract page number for section headers
|
| 522 |
+
parts = image_file.split('_')
|
| 523 |
+
if len(parts) >= 2:
|
| 524 |
+
page_num = parts[0].replace('page', '')
|
| 525 |
+
# Add page section header if we're on a new page
|
| 526 |
+
if current_page != page_num:
|
| 527 |
+
current_page = page_num
|
| 528 |
+
html += f"<h2 class='page-header'>Page {page_num}</h2>"
|
|
|
|
|
|
|
| 529 |
|
| 530 |
+
# In Hugging Face Spaces, files need the correct path
|
| 531 |
+
# This is the likely source of your error - incorrect path to the images
|
| 532 |
+
img_path = f"files/{image_file}" # Adjust this path based on your Hugging Face Space structure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
|
|
|
|
|
|
|
| 534 |
html += f"""
|
| 535 |
+
<div class='image-card'>
|
| 536 |
+
<div class='image-container'>
|
| 537 |
+
<img src="{img_path}" alt="{image_file}">
|
| 538 |
+
</div>
|
| 539 |
+
<div class='image-details'>
|
| 540 |
+
<h3>{image_file}</h3>
|
| 541 |
+
<p><strong>Page:</strong> {page_num}</p>
|
|
|
|
| 542 |
</div>
|
| 543 |
+
</div>
|
| 544 |
"""
|
| 545 |
|
| 546 |
html += "</div>"
|