Wajahat698 commited on
Commit
7c49c4d
·
verified ·
1 Parent(s): 09fef0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -597,8 +597,6 @@ def side():
597
  ("Bucket_COMPETENCE.png", "Competence"),
598
  ]
599
 
600
- #
601
-
602
  # CSS for layout and hover effect
603
  st.markdown(
604
  """
@@ -637,11 +635,33 @@ def side():
637
  unsafe_allow_html=True,
638
  )
639
 
640
- # Render images with hover text
641
  image_html = '<div class="image-container">'
642
- st.markdown(image_html, unsafe_allow_html=True)
 
 
643
 
 
 
 
 
 
 
 
 
 
 
644
 
 
 
 
 
 
 
 
 
 
 
645
 
646
 
647
 
 
597
  ("Bucket_COMPETENCE.png", "Competence"),
598
  ]
599
 
 
 
600
  # CSS for layout and hover effect
601
  st.markdown(
602
  """
 
635
  unsafe_allow_html=True,
636
  )
637
 
638
+ # Create HTML structure for images and hover text
639
  image_html = '<div class="image-container">'
640
+ for img_path, label in image_files:
641
+ # Load the image (you can use your local path or Hugging Face URL)
642
+ image = Image.open(img_path)
643
 
644
+ # Convert image to base64 for inline display in HTML
645
+ img_base64 = image_to_base64(image) # Function to convert image to base64
646
+
647
+ image_html += f"""
648
+ <div class="image-wrapper">
649
+ <img src="data:image/png;base64,{img_base64}" alt="{label}">
650
+ <div class="hover-text">{label}</div>
651
+ </div>
652
+ """
653
+ image_html += '</div>'
654
 
655
+ # Display images in the Streamlit app
656
+ st.markdown(image_html, unsafe_allow_html=True)
657
+
658
+ # Function to convert an image to base64
659
+ def image_to_base64(img):
660
+ from io import BytesIO
661
+ buffer = BytesIO()
662
+ img.save(buffer, format="PNG")
663
+ return buffer.getvalue().encode("base64").decode()
664
+
665
 
666
 
667