awacke1 commited on
Commit
263160d
โ€ข
1 Parent(s): 4cefb4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -752,12 +752,14 @@ def display_videos_and_links():
752
  col_index += 1 # Increment column index to place the next video in the next column
753
 
754
  @st.cache_resource
755
- def display_images_and_wikipedia_summaries():
756
  image_files = [f for f in os.listdir('.') if f.endswith('.png')]
757
  if not image_files:
758
  st.write("No PNG images found in the current directory.")
759
  return
760
  image_files_sorted = sorted(image_files, key=lambda x: len(x.split('.')[0]))
 
 
761
  grid_sizes = [len(f.split('.')[0]) for f in image_files_sorted]
762
  col_sizes = ['small' if size <= 4 else 'medium' if size <= 8 else 'large' for size in grid_sizes]
763
  num_columns_map = {"small": 4, "medium": 3, "large": 2}
@@ -772,7 +774,30 @@ def display_images_and_wikipedia_summaries():
772
  st.image(image, caption=image_file, use_column_width=True)
773
  k = image_file.split('.')[0] # Assumes keyword is the file name without extension
774
  display_glossary_entity(k)
775
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
776
  def get_all_query_params(key):
777
  return st.query_params().get(key, [])
778
 
 
752
  col_index += 1 # Increment column index to place the next video in the next column
753
 
754
  @st.cache_resource
755
+ def display_images_and_wikipedia_summariesold():
756
  image_files = [f for f in os.listdir('.') if f.endswith('.png')]
757
  if not image_files:
758
  st.write("No PNG images found in the current directory.")
759
  return
760
  image_files_sorted = sorted(image_files, key=lambda x: len(x.split('.')[0]))
761
+ num_columns=4
762
+
763
  grid_sizes = [len(f.split('.')[0]) for f in image_files_sorted]
764
  col_sizes = ['small' if size <= 4 else 'medium' if size <= 8 else 'large' for size in grid_sizes]
765
  num_columns_map = {"small": 4, "medium": 3, "large": 2}
 
774
  st.image(image, caption=image_file, use_column_width=True)
775
  k = image_file.split('.')[0] # Assumes keyword is the file name without extension
776
  display_glossary_entity(k)
777
+
778
+ @st.cache_resource
779
+ def display_images_and_wikipedia_summaries(num_columns=4):
780
+ image_files = [f for f in os.listdir('.') if f.endswith('.png')]
781
+ if not image_files:
782
+ st.write("No PNG images found in the current directory.")
783
+ return
784
+
785
+ image_files_sorted = sorted(image_files, key=lambda x: len(x.split('.')[0]))
786
+
787
+ cols = st.columns(num_columns) # Use specified num_columns for layout
788
+ col_index = 0 # Initialize column index for cycling through columns
789
+
790
+ for image_file in image_files_sorted:
791
+ with cols[col_index % num_columns]: # Cycle through columns based on num_columns
792
+ image = Image.open(image_file)
793
+ st.image(image, caption=image_file, use_column_width=True)
794
+ k = image_file.split('.')[0] # Assumes keyword is the file name without extension
795
+ display_glossary_entity(k)
796
+ col_index += 1 # Increment to move to the next column in the next iteration
797
+
798
+
799
+
800
+
801
  def get_all_query_params(key):
802
  return st.query_params().get(key, [])
803