Skip to content

Commit

Permalink
Gradio upgrade (#489)
Browse files Browse the repository at this point in the history
* upgrade gradio + mac filedialog

* .

---------

Co-authored-by: Josef Haupt <[email protected]>
  • Loading branch information
Josef-Haupt and Josef Haupt authored Oct 28, 2024
1 parent 7013520 commit 505fe19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions birdnet_analyzer/gui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@

# Nishant - Following two functions (select_folder andget_files_and_durations) are written for Folder selection
def select_folder(state_key=None):
from tkinter import Tk, filedialog
if sys.platform == "win32":
from tkinter import Tk, filedialog

tk = Tk()
tk.withdraw()

tk = Tk()
tk.withdraw()
initial_dir = loc.get_state(state_key, None) if state_key else None
initial_dir = loc.get_state(state_key, None) if state_key else None
folder_selected = filedialog.askdirectory(initialdir=initial_dir)

folder_selected = filedialog.askdirectory(initialdir=initial_dir)
tk.destroy()
tk.destroy()
else:
initial_dir = loc.get_state(state_key, "") if state_key else ""
dirname = _WINDOW.create_file_dialog(webview.FOLDER_DIALOG, directory=initial_dir)
folder_selected = dirname[0] if dirname else None

if folder_selected and state_key:
loc.set_state(state_key, folder_selected)
Expand Down Expand Up @@ -475,8 +481,8 @@ def open_window(builder: list[Callable] | Callable):
multiprocessing.freeze_support()

with gr.Blocks(
css=os.path.join(SCRIPT_DIR, "assets/gui.css"),
js=os.path.join(SCRIPT_DIR, "assets/gui.js"),
css=open(os.path.join(SCRIPT_DIR, "assets/gui.css")).read(),
js=open(os.path.join(SCRIPT_DIR, "assets/gui.js")).read(),
theme=gr.themes.Default(),
analytics_enabled=False,
) as demo:
Expand All @@ -491,7 +497,7 @@ def open_window(builder: list[Callable] | Callable):
build_settings()
build_footer()

url = demo.queue(api_open=False).launch(prevent_thread_lock=True, quiet=True)[1]
url = demo.queue(api_open=False).launch(prevent_thread_lock=True, quiet=True, show_api=False, enable_monitoring=False)[1]
_WINDOW = webview.create_window("BirdNET-Analyzer", url.rstrip("/") + "?__theme=light", min_size=(1024, 768))
set_window(_WINDOW)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
librosa==0.9.2
resampy
tensorflow==2.15.0
gradio==4.41.0
gradio==5.4.0
pywebview
tqdm
bottle
Expand Down

0 comments on commit 505fe19

Please sign in to comment.