bradley6597
commited on
Commit
•
0a222a5
1
Parent(s):
04faab6
Add image type filter
Browse files
app.py
CHANGED
@@ -87,10 +87,7 @@ def same_auth(username, password):
|
|
87 |
return(username == os.environ['username']) & (password == os.environ['password'])
|
88 |
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_title, increase = None):
|
94 |
max_results_list = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All']
|
95 |
if increase:
|
96 |
max_results = max_results_list[max_results_list.index(max_results) + 1]
|
@@ -141,7 +138,10 @@ def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_tit
|
|
141 |
output_df2 = output_df2.sort_values(by = ['Date Created'], ascending = False)
|
142 |
elif sort_by == 'A-Z':
|
143 |
output_df2 = output_df2.sort_values(by = ['title'], ascending = True)
|
144 |
-
|
|
|
|
|
|
|
145 |
total_returned = 'No. of Results to Return (Total: ' + str(output_df2.shape[0]) + ')'
|
146 |
|
147 |
if max_results != 'All':
|
@@ -257,6 +257,8 @@ with gr.Blocks(css=style) as app:
|
|
257 |
# with gr.Row():
|
258 |
shared_drive = gr.Dropdown(choices = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now', 'Shutter Stock Images'], multiselect = True, label = 'Shared Drive', value = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'])
|
259 |
key_stage = gr.Dropdown(choices = ['EYFS', 'KS1', 'KS2'], multiselect = True, label = 'Key Stage', value = ['EYFS', 'KS1', 'KS2'])
|
|
|
|
|
260 |
sort_by = gr.Dropdown(choices = ['Relevance', 'Date Created', 'A-Z'], value = 'Relevance', multiselect = False, label = 'Sort By')
|
261 |
max_return = gr.Dropdown(choices = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All'], value = '50', multiselect = False, label = 'No. of Results to Return (Total: 0)')
|
262 |
with gr.Row():
|
@@ -265,11 +267,11 @@ with gr.Blocks(css=style) as app:
|
|
265 |
output_df = gr.HTML()
|
266 |
back_top_btn = gr.HTML(back_to_top_btn_html)
|
267 |
load_more_results_btn = gr.Button(value = 'Load More Results', interactive = True, visible = False)
|
268 |
-
search_button.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search], outputs=[output_df, max_return, load_more_results_btn])
|
269 |
-
search_prompt.submit(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search], outputs=[output_df, max_return, load_more_results_btn])
|
270 |
search_button.click(search_logging, inputs=[search_prompt], outputs=None)
|
271 |
search_prompt.submit(search_logging, inputs=[search_prompt], outputs=None)
|
272 |
-
load_more_results_btn.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, load_more_results_btn], outputs=[output_df, max_return, load_more_results_btn])
|
273 |
app.load(_js = logging_js)
|
274 |
|
275 |
app.auth = (same_auth)
|
|
|
87 |
return(username == os.environ['username']) & (password == os.environ['password'])
|
88 |
|
89 |
|
90 |
+
def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_title, image_type, increase = None):
|
|
|
|
|
|
|
91 |
max_results_list = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All']
|
92 |
if increase:
|
93 |
max_results = max_results_list[max_results_list.index(max_results) + 1]
|
|
|
138 |
output_df2 = output_df2.sort_values(by = ['Date Created'], ascending = False)
|
139 |
elif sort_by == 'A-Z':
|
140 |
output_df2 = output_df2.sort_values(by = ['title'], ascending = True)
|
141 |
+
|
142 |
+
image_type_filter = '$|'.join(image_type).lower().replace("jpeg", "jpg") + '$'
|
143 |
+
|
144 |
+
output_df2 = output_df2[output_df2['filepath'].str.contains(image_type_filter, regex = True)].reset_index(drop = True)
|
145 |
total_returned = 'No. of Results to Return (Total: ' + str(output_df2.shape[0]) + ')'
|
146 |
|
147 |
if max_results != 'All':
|
|
|
257 |
# with gr.Row():
|
258 |
shared_drive = gr.Dropdown(choices = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now', 'Shutter Stock Images'], multiselect = True, label = 'Shared Drive', value = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'])
|
259 |
key_stage = gr.Dropdown(choices = ['EYFS', 'KS1', 'KS2'], multiselect = True, label = 'Key Stage', value = ['EYFS', 'KS1', 'KS2'])
|
260 |
+
image_type = gr.Dropdown(choices = ['JPEG', 'PNG', 'TIF'], multiselect = True, label = 'Image Type', value = ['PNG', 'JPEG', 'TIF'])
|
261 |
+
|
262 |
sort_by = gr.Dropdown(choices = ['Relevance', 'Date Created', 'A-Z'], value = 'Relevance', multiselect = False, label = 'Sort By')
|
263 |
max_return = gr.Dropdown(choices = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All'], value = '50', multiselect = False, label = 'No. of Results to Return (Total: 0)')
|
264 |
with gr.Row():
|
|
|
267 |
output_df = gr.HTML()
|
268 |
back_top_btn = gr.HTML(back_to_top_btn_html)
|
269 |
load_more_results_btn = gr.Button(value = 'Load More Results', interactive = True, visible = False)
|
270 |
+
search_button.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type], outputs=[output_df, max_return, load_more_results_btn])
|
271 |
+
search_prompt.submit(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type], outputs=[output_df, max_return, load_more_results_btn])
|
272 |
search_button.click(search_logging, inputs=[search_prompt], outputs=None)
|
273 |
search_prompt.submit(search_logging, inputs=[search_prompt], outputs=None)
|
274 |
+
load_more_results_btn.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search, image_type, load_more_results_btn], outputs=[output_df, max_return, load_more_results_btn])
|
275 |
app.load(_js = logging_js)
|
276 |
|
277 |
app.auth = (same_auth)
|