Your Name
commited on
Commit
·
35379ab
1
Parent(s):
dddb9f9
update dropdown
Browse files- __pycache__/app.cpython-310.pyc +0 -0
- __pycache__/bird_ast_model.cpython-310.pyc +0 -0
- __pycache__/utils.cpython-310.pyc +0 -0
- app.py +13 -6
__pycache__/app.cpython-310.pyc
CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
|
|
__pycache__/bird_ast_model.cpython-310.pyc
CHANGED
Binary files a/__pycache__/bird_ast_model.cpython-310.pyc and b/__pycache__/bird_ast_model.cpython-310.pyc differ
|
|
__pycache__/utils.cpython-310.pyc
CHANGED
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
|
|
app.py
CHANGED
@@ -265,7 +265,7 @@ References
|
|
265 |
"""
|
266 |
|
267 |
# Function to handle model selection
|
268 |
-
def handle_model_selection(model_name):
|
269 |
# Inform user that download is starting
|
270 |
# gr.Info(f"Downloading model weights for {model_name}...")
|
271 |
print(f"Downloading model weights for {model_name}...")
|
@@ -273,10 +273,12 @@ def handle_model_selection(model_name):
|
|
273 |
model_weights_url = assets["model_weights"]
|
274 |
download_flag = True
|
275 |
try:
|
276 |
-
|
|
|
277 |
weight_file = os.path.join(ASSET_DIR, model_weight.split("/")[-1])
|
278 |
print(weight_file)
|
279 |
if not os.path.exists(weight_file):
|
|
|
280 |
download_model(model_weight, weight_file)
|
281 |
|
282 |
if not os.path.exists(weight_file):
|
@@ -284,12 +286,14 @@ def handle_model_selection(model_name):
|
|
284 |
break
|
285 |
|
286 |
if download_flag:
|
287 |
-
|
288 |
else:
|
289 |
-
|
290 |
|
291 |
except Exception as e:
|
292 |
-
|
|
|
|
|
293 |
|
294 |
|
295 |
with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
|
@@ -301,7 +305,10 @@ with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
|
|
301 |
# add dropdown for model selection
|
302 |
model_names = ['BirdAST', 'BirdAST_Seq', 'EfficientNet']
|
303 |
model_dropdown = gr.Dropdown(label="Choose a model", choices=model_names)
|
304 |
-
|
|
|
|
|
|
|
305 |
|
306 |
with gr.Row():
|
307 |
with gr.Column(elem_classes="column-container"):
|
|
|
265 |
"""
|
266 |
|
267 |
# Function to handle model selection
|
268 |
+
def handle_model_selection(model_name, download_status):
|
269 |
# Inform user that download is starting
|
270 |
# gr.Info(f"Downloading model weights for {model_name}...")
|
271 |
print(f"Downloading model weights for {model_name}...")
|
|
|
273 |
model_weights_url = assets["model_weights"]
|
274 |
download_flag = True
|
275 |
try:
|
276 |
+
total_files = len(model_weights_url)
|
277 |
+
for idx, model_weight in enumerate(model_weights_url):
|
278 |
weight_file = os.path.join(ASSET_DIR, model_weight.split("/")[-1])
|
279 |
print(weight_file)
|
280 |
if not os.path.exists(weight_file):
|
281 |
+
download_status = f"Downloading {idx + 1} of {total_files}"
|
282 |
download_model(model_weight, weight_file)
|
283 |
|
284 |
if not os.path.exists(weight_file):
|
|
|
286 |
break
|
287 |
|
288 |
if download_flag:
|
289 |
+
download_status = f"Model {model_name} is ready for prediction!"
|
290 |
else:
|
291 |
+
download_status = f"An error occurred while downloading model weights."
|
292 |
|
293 |
except Exception as e:
|
294 |
+
download_status = f"An error occurred while downloading model weights."
|
295 |
+
|
296 |
+
return download_status
|
297 |
|
298 |
|
299 |
with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
|
|
|
305 |
# add dropdown for model selection
|
306 |
model_names = ['BirdAST', 'BirdAST_Seq', 'EfficientNet']
|
307 |
model_dropdown = gr.Dropdown(label="Choose a model", choices=model_names)
|
308 |
+
download_status = gr.Textbox(label="Model Status", lines=3, value='', interactive=False) # Non-interactive textbox for status
|
309 |
+
|
310 |
+
model_dropdown.change(handle_model_selection, inputs=[model_dropdown, download_status], outputs=download_status)
|
311 |
+
|
312 |
|
313 |
with gr.Row():
|
314 |
with gr.Column(elem_classes="column-container"):
|