Spaces:
Sleeping
Sleeping
Added small object search
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
-
from helper import
|
3 |
import os
|
4 |
import time
|
5 |
|
@@ -7,8 +7,11 @@ import time
|
|
7 |
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID")
|
8 |
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY")
|
9 |
# Predefined list of datasets
|
10 |
-
datasets = ["WayveScenes","MajorTom-Europe"] # Example dataset names
|
11 |
-
|
|
|
|
|
|
|
12 |
# AWS S3 bucket name
|
13 |
bucket_name = "datasets-quasara-io"
|
14 |
|
@@ -18,8 +21,12 @@ def main():
|
|
18 |
|
19 |
# Select dataset from dropdown
|
20 |
dataset_name = st.selectbox("Select Dataset", datasets)
|
21 |
-
folder_path = f'{dataset_name}/'
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
# Progress bar for loading dataset
|
24 |
loading_text = st.empty() # Placeholder for dynamic text
|
25 |
loading_text.text("Loading dataset...")
|
@@ -31,7 +38,7 @@ def main():
|
|
31 |
progress_bar.progress(i + 25)
|
32 |
|
33 |
# Load the selected dataset
|
34 |
-
|
35 |
|
36 |
# Complete progress when loading is done
|
37 |
progress_bar.progress(100)
|
@@ -42,7 +49,13 @@ def main():
|
|
42 |
|
43 |
# Number of results to display
|
44 |
limit = st.number_input("Number of results to display", min_value=1, max_value=10, value=10)
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Search button
|
47 |
if st.button("Search"):
|
48 |
# Validate input
|
@@ -59,22 +72,39 @@ def main():
|
|
59 |
time.sleep(0.3) # Simulate work being done
|
60 |
search_progress_bar.progress(i + 25)
|
61 |
|
62 |
-
#
|
63 |
-
|
|
|
64 |
|
65 |
-
#
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
else:
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
|
|
79 |
if __name__ == "__main__":
|
80 |
-
main()
|
|
|
1 |
import streamlit as st
|
2 |
+
from helper import load_dataset, parallel_load_and_combine,search, get_file_paths, get_cordinates, get_images_from_s3_to_display, get_images_with_bounding_boxes_from_s3, batch_search
|
3 |
import os
|
4 |
import time
|
5 |
|
|
|
7 |
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID")
|
8 |
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY")
|
9 |
# Predefined list of datasets
|
10 |
+
datasets = ["StopSign_test","WayveScenes","MajorTom-Europe"] # Example dataset names
|
11 |
+
description = {
|
12 |
+
"StopSign_test" : "A test dataset for me",
|
13 |
+
"WayveScenes": "A large-scale dataset featuring diverse urban driving scenes, captured from autonomous vehicles to advance AI perception and navigation in complex environments.",
|
14 |
+
"MajorTom-Europe": "A geospatial dataset containing satellite imagery from across Europe, designed for tasks like land-use classification, environmental monitoring, and earth observation analytics."}
|
15 |
# AWS S3 bucket name
|
16 |
bucket_name = "datasets-quasara-io"
|
17 |
|
|
|
21 |
|
22 |
# Select dataset from dropdown
|
23 |
dataset_name = st.selectbox("Select Dataset", datasets)
|
|
|
24 |
|
25 |
+
if dataset_name == 'StopSign_test':
|
26 |
+
folder_path = ""
|
27 |
+
else:
|
28 |
+
folder_path = f'{dataset_name}/'
|
29 |
+
st.caption(description[dataset_name]) #trial area
|
30 |
# Progress bar for loading dataset
|
31 |
loading_text = st.empty() # Placeholder for dynamic text
|
32 |
loading_text.text("Loading dataset...")
|
|
|
38 |
progress_bar.progress(i + 25)
|
39 |
|
40 |
# Load the selected dataset
|
41 |
+
dataset = load_dataset(f"quasara-io/{dataset_name}")
|
42 |
|
43 |
# Complete progress when loading is done
|
44 |
progress_bar.progress(100)
|
|
|
49 |
|
50 |
# Number of results to display
|
51 |
limit = st.number_input("Number of results to display", min_value=1, max_value=10, value=10)
|
52 |
+
if st.checkbox("Enable Small Object Search"):
|
53 |
+
search_in_small_objects = True
|
54 |
+
st.text("Small Object Search Enabled")
|
55 |
+
else:
|
56 |
+
search_in_small_objects = False
|
57 |
+
st.text("Small Object Search Disabled")
|
58 |
+
|
59 |
# Search button
|
60 |
if st.button("Search"):
|
61 |
# Validate input
|
|
|
72 |
time.sleep(0.3) # Simulate work being done
|
73 |
search_progress_bar.progress(i + 25)
|
74 |
|
75 |
+
#Get Dataset Keys to speed up processing/search
|
76 |
+
dataset_keys = dataset.keys()
|
77 |
+
main_df,split_df = parallel_load_and_combine(dataset_keys,dataset)
|
78 |
|
79 |
+
#Small Search
|
80 |
+
if search_in_small_objects:
|
81 |
+
# Perform the search
|
82 |
+
results = batch_search(query, split_df)
|
83 |
+
top_k_paths = get_file_paths(split_df,results)
|
84 |
+
top_k_cordinates = get_cordinates(split_df, results)
|
85 |
+
# Complete the search progress
|
86 |
+
search_progress_bar.progress(100)
|
87 |
+
search_loading_text.text("Search completed!")
|
88 |
+
#Load Images with Bounding boxes
|
89 |
+
if top_k_paths and top_k_cordinates:
|
90 |
+
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)
|
91 |
+
else:
|
92 |
+
st.write("No results found.")
|
93 |
else:
|
94 |
+
#Normal Search
|
95 |
+
results = batch_search(query, main_df)
|
96 |
+
top_k_paths = get_file_paths(main_df, results)
|
97 |
+
# Complete the search progress
|
98 |
+
search_progress_bar.progress(100)
|
99 |
+
search_loading_text.text("Search completed!")
|
100 |
+
#Load Images
|
101 |
+
# Display images from S3
|
102 |
+
if top_k_paths:
|
103 |
+
st.write(f"Displaying top {len(top_k_paths)} results for query '{query}':")
|
104 |
+
get_images_from_s3_to_display(bucket_name, top_k_paths, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, folder_path)
|
105 |
+
else:
|
106 |
+
st.write("No results found.")
|
107 |
|
108 |
+
|
109 |
if __name__ == "__main__":
|
110 |
+
main()
|