inie2003 commited on
Commit
4e43718
·
verified ·
1 Parent(s): 634aa81

more experiemtns

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -56,6 +56,7 @@ def main():
56
 
57
  # Select dataset from dropdown
58
  dataset_name = st.selectbox("Select Dataset", datasets)
 
59
  #For Loading from Box
60
  folder_path = folder_path_dict[dataset_name]
61
 
@@ -65,11 +66,13 @@ def main():
65
  st.session_state.search_in_small_objects = True
66
  st.text("Small Object Search Enabled")
67
  st.session_state.dataset_number = st.selectbox("Select Subset of Data", list(range(1, selection[dataset_name][1] + 1)))
 
68
  st.text(f"You have selected Split Dataset {st.session_state.dataset_number}")
69
  else:
70
  st.session_state.search_in_small_objects = False
71
  st.text("Small Object Search Disabled")
72
  st.session_state.dataset_number = st.selectbox("Select Subset of Data", list(range(1, selection[dataset_name][0] + 1)))
 
73
  st.text(f"You have selected Main Dataset {st.session_state.dataset_number}")
74
 
75
  df, total_rows = load_dataset_with_limit(dataset_name, st.session_state.dataset_number, st.session_state.search_in_small_objects, limit=1)
@@ -110,13 +113,11 @@ def main():
110
 
111
  # Number of results to display
112
  limit = st.number_input("Number of results to display", min_value=1, max_value=10, value=10)
113
-
114
- # Search button
115
- if st.button("Search"):
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.")
@@ -126,7 +127,7 @@ def main():
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:
@@ -139,11 +140,11 @@ def main():
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)
 
56
 
57
  # Select dataset from dropdown
58
  dataset_name = st.selectbox("Select Dataset", datasets)
59
+ st.session_state.df = None
60
  #For Loading from Box
61
  folder_path = folder_path_dict[dataset_name]
62
 
 
66
  st.session_state.search_in_small_objects = True
67
  st.text("Small Object Search Enabled")
68
  st.session_state.dataset_number = st.selectbox("Select Subset of Data", list(range(1, selection[dataset_name][1] + 1)))
69
+ st.session_state.df = None
70
  st.text(f"You have selected Split Dataset {st.session_state.dataset_number}")
71
  else:
72
  st.session_state.search_in_small_objects = False
73
  st.text("Small Object Search Disabled")
74
  st.session_state.dataset_number = st.selectbox("Select Subset of Data", list(range(1, selection[dataset_name][0] + 1)))
75
+ st.session_state.df = None
76
  st.text(f"You have selected Main Dataset {st.session_state.dataset_number}")
77
 
78
  df, total_rows = load_dataset_with_limit(dataset_name, st.session_state.dataset_number, st.session_state.search_in_small_objects, limit=1)
 
113
 
114
  # Number of results to display
115
  limit = st.number_input("Number of results to display", min_value=1, max_value=10, value=10)
116
+ if st.session_state.df == None and st.button("Search"):
117
+ st.warning("Please Load Datset")
118
+ else:
119
+ # Search button
120
+ if st.button("Search"):
 
 
121
  # Validate input
122
  if not query:
123
  st.warning("Please enter a search query.")
 
127
  search_loading_text = st.empty()
128
  search_loading_text.text("Searching...")
129
  search_progress_bar = st.progress(0)
130
+
131
  # Perform search on the loaded dataset from session state
132
  df = st.session_state.df
133
  if st.session_state.search_in_small_objects:
 
140
  results = search(query, df, limit)
141
  top_k_paths = get_file_paths(df, results)
142
  search_type = 'Main'
143
+
144
  # Complete the search progress
145
  search_progress_bar.progress(100)
146
  search_loading_text.text(f"Search completed among {dataset_limit} rows for {dataset_name} in {search_type} {st.session_state.dataset_number}")
147
+
148
  # Load Images with Bounding Boxes if applicable
149
  if st.session_state.search_in_small_objects and top_k_paths and top_k_cordinates:
150
  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)