awacke1 commited on
Commit
523c705
ยท
verified ยท
1 Parent(s): b16158e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -916,7 +916,7 @@ def display_videos_and_links(num_columns):
916
  display_glossary_entity(k)
917
  col_index += 1 # Increment column index to place the next video in the next column
918
 
919
- #@st.cache_resource
920
  def display_images_and_wikipedia_summaries(num_columns=4):
921
  image_files = [f for f in os.listdir('.') if f.endswith('.png')]
922
  if not image_files:
@@ -928,12 +928,29 @@ def display_images_and_wikipedia_summaries(num_columns=4):
928
  cols = st.columns(num_columns) # Use specified num_columns for layout
929
  col_index = 0 # Initialize column index for cycling through columns
930
 
 
931
  for image_file in image_files_sorted:
932
  with cols[col_index % num_columns]: # Cycle through columns based on num_columns
933
- image = Image.open(image_file)
934
- st.image(image, caption=image_file, use_column_width=True)
935
- k = image_file.split('.')[0] # Assumes keyword is the file name without extension
936
- display_glossary_entity(k)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
937
  col_index += 1 # Increment to move to the next column in the next iteration
938
 
939
 
 
916
  display_glossary_entity(k)
917
  col_index += 1 # Increment column index to place the next video in the next column
918
 
919
+ # Image Prompt
920
  def display_images_and_wikipedia_summaries(num_columns=4):
921
  image_files = [f for f in os.listdir('.') if f.endswith('.png')]
922
  if not image_files:
 
928
  cols = st.columns(num_columns) # Use specified num_columns for layout
929
  col_index = 0 # Initialize column index for cycling through columns
930
 
931
+ errored = False
932
  for image_file in image_files_sorted:
933
  with cols[col_index % num_columns]: # Cycle through columns based on num_columns
934
+ try:
935
+ image = Image.open(image_file)
936
+ #st.image(image, caption=image_file, use_column_width=True)
937
+ st.image(image, use_column_width=True)
938
+ k = image_file.split('.')[0] # Assumes keyword is the file name without extension
939
+ display_glossary_entity(k)
940
+
941
+ # Add text input for image file
942
+ #image_text_input = st.text_input(f"Image Prompt for {image_file}", key=f"image_prompt_{image_file}")
943
+ #image_text_input = st.text_input(f"Image Prompt:", key=f"image_prompt_{image_file}")
944
+ image_text_input = st.text_input(key=f"image_prompt_{image_file}")
945
+ if (len(image_text_input) > 0):
946
+ #image_response = process_image(image, image_text_input)
947
+ image_response = process_image(image_file, image_text_input)
948
+
949
+ with st.chat_message(name="ai", avatar="๐Ÿฆ–"):
950
+ st.markdown(image_response)
951
+ except:
952
+ errored = True
953
+
954
  col_index += 1 # Increment to move to the next column in the next iteration
955
 
956