inie2003 commited on
Commit
634aa81
·
verified ·
1 Parent(s): 9ea3427

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -39
app.py CHANGED
@@ -116,46 +116,47 @@ def main():
116
  #Ensure Dataset is selected
117
  if 'df' not in st.session_state:
118
  st.warning("You have not selected a Dataset. Please click on Load Dataset to load your respective Dataset")
119
- # Validate input
120
- if not query:
121
- st.warning("Please enter a search query.")
122
  else:
123
- try:
124
- # Progress bar for search
125
- search_loading_text = st.empty()
126
- search_loading_text.text("Searching...")
127
- search_progress_bar = st.progress(0)
128
-
129
- # Perform search on the loaded dataset from session state
130
- df = st.session_state.df
131
- if st.session_state.search_in_small_objects:
132
- results = search(query, df, limit)
133
- top_k_paths = get_file_paths(df, results)
134
- top_k_cordinates = get_cordinates(df, results)
135
- search_type = 'Splits'
136
- else:
137
- # Normal Search
138
- results = search(query, df, limit)
139
- top_k_paths = get_file_paths(df, results)
140
- search_type = 'Main'
141
-
142
- # Complete the search progress
143
- search_progress_bar.progress(100)
144
- search_loading_text.text(f"Search completed among {dataset_limit} for {dataset_name} in {search_type} {st.session_state.dataset_number}")
145
-
146
- # Load Images with Bounding Boxes if applicable
147
- if st.session_state.search_in_small_objects and top_k_paths and top_k_cordinates:
148
- get_images_with_bounding_boxes_from_s3(bucket_name, top_k_paths, top_k_cordinates, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, folder_path)
149
- elif not st.session_state.search_in_small_objects and top_k_paths:
150
- st.write(f"Displaying top {len(top_k_paths)} results for query '{query}':")
151
- get_images_from_s3_to_display(bucket_name, top_k_paths, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, folder_path)
152
-
153
- else:
154
- st.write("No results found.")
155
-
156
-
157
- except Exception as e:
158
- st.error(f"Search failed: {e}")
 
 
 
 
159
 
160
  if __name__ == "__main__":
161
  main()
 
116
  #Ensure Dataset is selected
117
  if 'df' not in st.session_state:
118
  st.warning("You have not selected a Dataset. Please click on Load Dataset to load your respective Dataset")
 
 
 
119
  else:
120
+ # Validate input
121
+ if not query:
122
+ st.warning("Please enter a search query.")
123
+ else:
124
+ try:
125
+ # Progress bar for search
126
+ search_loading_text = st.empty()
127
+ search_loading_text.text("Searching...")
128
+ search_progress_bar = st.progress(0)
129
+
130
+ # Perform search on the loaded dataset from session state
131
+ df = st.session_state.df
132
+ if st.session_state.search_in_small_objects:
133
+ results = search(query, df, limit)
134
+ top_k_paths = get_file_paths(df, results)
135
+ top_k_cordinates = get_cordinates(df, results)
136
+ search_type = 'Splits'
137
+ else:
138
+ # Normal Search
139
+ results = search(query, df, limit)
140
+ top_k_paths = get_file_paths(df, results)
141
+ search_type = 'Main'
142
+
143
+ # Complete the search progress
144
+ search_progress_bar.progress(100)
145
+ search_loading_text.text(f"Search completed among {dataset_limit} rows for {dataset_name} in {search_type} {st.session_state.dataset_number}")
146
+
147
+ # Load Images with Bounding Boxes if applicable
148
+ if st.session_state.search_in_small_objects and top_k_paths and top_k_cordinates:
149
+ get_images_with_bounding_boxes_from_s3(bucket_name, top_k_paths, top_k_cordinates, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, folder_path)
150
+ elif not st.session_state.search_in_small_objects and top_k_paths:
151
+ st.write(f"Displaying top {len(top_k_paths)} results for query '{query}':")
152
+ get_images_from_s3_to_display(bucket_name, top_k_paths, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, folder_path)
153
+
154
+ else:
155
+ st.write("No results found.")
156
+
157
+
158
+ except Exception as e:
159
+ st.error(f"Search failed: {e}")
160
 
161
  if __name__ == "__main__":
162
  main()