Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradio upgrade #489

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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