Spaces:
Sleeping
Sleeping
Commit ·
0c1027f
1
Parent(s): b0f5b8d
feat(ui): refine validation labels and audio title behavior
Browse files- src/ui/app_factory.py +187 -177
src/ui/app_factory.py
CHANGED
|
@@ -1271,9 +1271,9 @@ def _build_validation_summary_cards(rows: object) -> str:
|
|
| 1271 |
|
| 1272 |
return (
|
| 1273 |
"<div style='display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:12px;margin:4px 0 12px 0;'>"
|
| 1274 |
-
f"<div style='padding:10px 14px;border-radius:10px;background:#ececec;'><div style='font-size:12px;color:#555;'>Total</div><div style='font-size:24px;font-weight:700;color:#222;'>{total}</div></div>"
|
| 1275 |
-
f"<div style='padding:10px 14px;border-radius:10px;background:#e7f4ea;'><div style='font-size:12px;color:#3f6c49;'>
|
| 1276 |
-
f"<div style='padding:10px 14px;border-radius:10px;background:#fdeaea;'><div style='font-size:12px;color:#7b3a3a;'>
|
| 1277 |
"</div>"
|
| 1278 |
)
|
| 1279 |
|
|
@@ -1336,10 +1336,45 @@ def _normalize_rows(rows: object) -> list[list[object]]:
|
|
| 1336 |
return [list(item) for item in rows] if rows else []
|
| 1337 |
|
| 1338 |
|
| 1339 |
-
def _spectrogram_title(
|
| 1340 |
-
if not
|
| 1341 |
-
return "###
|
| 1342 |
-
return f"###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1343 |
|
| 1344 |
|
| 1345 |
def _paginate_rows(rows: list[list[object]], page: int, page_size: int) -> tuple[list[list[object]], int, int]:
|
|
@@ -1403,7 +1438,8 @@ def _fetch_selected_audio_with_title(
|
|
| 1403 |
allow_demo_fallback=allow_demo_fallback,
|
| 1404 |
hf_token=hf_token,
|
| 1405 |
)
|
| 1406 |
-
|
|
|
|
| 1407 |
|
| 1408 |
|
| 1409 |
def _select_and_fetch_audio_with_title(
|
|
@@ -1424,13 +1460,14 @@ def _select_and_fetch_audio_with_title(
|
|
| 1424 |
allow_demo_fallback=allow_demo_fallback,
|
| 1425 |
hf_token=hf_token,
|
| 1426 |
)
|
|
|
|
| 1427 |
return (
|
| 1428 |
selected_index,
|
| 1429 |
audio_path,
|
| 1430 |
updated_cache_key,
|
| 1431 |
status,
|
| 1432 |
spectrogram_path,
|
| 1433 |
-
_spectrogram_title(
|
| 1434 |
)
|
| 1435 |
|
| 1436 |
|
|
@@ -1450,13 +1487,14 @@ def _autofetch_first_row_with_title(
|
|
| 1450 |
allow_demo_fallback=allow_demo_fallback,
|
| 1451 |
hf_token=hf_token,
|
| 1452 |
)
|
|
|
|
| 1453 |
return (
|
| 1454 |
selected_index,
|
| 1455 |
audio_path,
|
| 1456 |
updated_cache_key,
|
| 1457 |
status,
|
| 1458 |
spectrogram_path,
|
| 1459 |
-
_spectrogram_title(
|
| 1460 |
)
|
| 1461 |
|
| 1462 |
|
|
@@ -1483,7 +1521,8 @@ def _advance_to_next_row_with_title(
|
|
| 1483 |
allow_demo_fallback=allow_demo_fallback,
|
| 1484 |
hf_token=hf_token,
|
| 1485 |
)
|
| 1486 |
-
|
|
|
|
| 1487 |
|
| 1488 |
|
| 1489 |
def _cleanup_selected_audio(audio_service: _AudioServiceProtocol, cache_key: str) -> tuple[str, str | None]:
|
|
@@ -2431,8 +2470,8 @@ def create_app() -> gr.Blocks:
|
|
| 2431 |
validation_repository = AppendOnlyValidationRepository(base_dir=runtime_config.validation_base_dir)
|
| 2432 |
validation_service = ValidationService(validation_repository)
|
| 2433 |
|
| 2434 |
-
with gr.Blocks(title="BirdNET-Validator-App
|
| 2435 |
-
gr.Markdown("# BirdNET-Validator-App
|
| 2436 |
gr.Markdown("**Version with authentication, project-level authorization, and admin panel**")
|
| 2437 |
if bootstrap_warning:
|
| 2438 |
gr.Markdown(bootstrap_warning)
|
|
@@ -3054,12 +3093,12 @@ def create_app() -> gr.Blocks:
|
|
| 3054 |
return (
|
| 3055 |
gr.Dropdown(choices=[], value=None, interactive=False),
|
| 3056 |
(
|
| 3057 |
-
"ℹ️ **
|
| 3058 |
-
"
|
| 3059 |
-
"1.
|
| 3060 |
-
"2.
|
| 3061 |
-
"3.
|
| 3062 |
-
"4.
|
| 3063 |
),
|
| 3064 |
None,
|
| 3065 |
"",
|
|
@@ -3315,30 +3354,34 @@ def create_app() -> gr.Blocks:
|
|
| 3315 |
with gr.Column(scale=8):
|
| 3316 |
validation_summary_cards = gr.HTML(value=_build_validation_summary_cards([]))
|
| 3317 |
|
| 3318 |
-
spectrogram_title = gr.Markdown("###
|
| 3319 |
spectrogram_image = gr.Image(
|
| 3320 |
label="",
|
| 3321 |
type="filepath",
|
| 3322 |
interactive=False,
|
| 3323 |
height=330,
|
| 3324 |
)
|
| 3325 |
-
|
|
|
|
|
|
|
| 3326 |
|
| 3327 |
with gr.Row():
|
| 3328 |
-
approve_btn = gr.Button("
|
| 3329 |
-
reject_btn = gr.Button("
|
| 3330 |
uncertain_btn = gr.Button("Uncertain")
|
| 3331 |
skip_btn = gr.Button("Skip")
|
| 3332 |
-
favorite_btn = gr.Button("
|
| 3333 |
|
| 3334 |
corrected_species_input = gr.Dropdown(
|
| 3335 |
-
label="
|
| 3336 |
-
choices=["
|
| 3337 |
allow_custom_value=True,
|
| 3338 |
filterable=True,
|
| 3339 |
value=None,
|
| 3340 |
)
|
| 3341 |
|
|
|
|
|
|
|
| 3342 |
table = gr.Dataframe(
|
| 3343 |
headers=[
|
| 3344 |
"detection_key",
|
|
@@ -3356,24 +3399,22 @@ def create_app() -> gr.Blocks:
|
|
| 3356 |
interactive=False,
|
| 3357 |
)
|
| 3358 |
selected_index = gr.Number(label="Selected row", value=0, precision=0, visible=False)
|
| 3359 |
-
status = gr.Textbox(label="Status", interactive=False)
|
| 3360 |
|
| 3361 |
with gr.Column(scale=4):
|
| 3362 |
dataset_repo = gr.Textbox(label="Dataset repo", interactive=False)
|
| 3363 |
species_filter = gr.Dropdown(
|
| 3364 |
-
label="
|
| 3365 |
choices=[],
|
| 3366 |
value=None,
|
| 3367 |
interactive=False,
|
| 3368 |
)
|
| 3369 |
|
| 3370 |
-
gr.Markdown("####
|
| 3371 |
with gr.Row():
|
| 3372 |
-
prev_btn = gr.Button("
|
| 3373 |
-
next_btn = gr.Button("
|
| 3374 |
-
refresh_btn = gr.Button("Apply")
|
| 3375 |
|
| 3376 |
-
gr.Markdown("####
|
| 3377 |
min_confidence = gr.Slider(label="Minimum confidence", minimum=0.0, maximum=1.0, step=0.01, value=0.0)
|
| 3378 |
validator_filter = gr.Textbox(label="Validator filter", placeholder="Ex: validator-demo")
|
| 3379 |
validation_status_filter = gr.Dropdown(
|
|
@@ -3383,31 +3424,26 @@ def create_app() -> gr.Blocks:
|
|
| 3383 |
)
|
| 3384 |
updated_after_filter = gr.DateTime(label="Updated since", include_time=False, type="string")
|
| 3385 |
show_conflicts_only = gr.Checkbox(label="Show only conflicts", value=False)
|
|
|
|
| 3386 |
|
| 3387 |
-
gr.Markdown("####
|
| 3388 |
validator_name = gr.Textbox(label="Validator", value="validator-demo")
|
| 3389 |
-
validation_notes = gr.Textbox(label="Notes", placeholder="
|
| 3390 |
-
load_audio_btn = gr.Button("Load selected audio")
|
| 3391 |
-
clear_audio_btn = gr.Button("Clear cached audio")
|
| 3392 |
-
reapply_btn = gr.Button("Reapply validation after conflict")
|
| 3393 |
-
batch_approve_conflicts_btn = gr.Button("Approve all conflicts")
|
| 3394 |
-
batch_reject_conflicts_btn = gr.Button("Reject all conflicts")
|
| 3395 |
report_btn = gr.Button("Generate validation report")
|
| 3396 |
|
| 3397 |
keyboard_shortcuts_info = gr.HTML(
|
| 3398 |
value="<div style='font-size:12px;color:#333;padding:8px 10px;background:#f5f5f5;border-radius:6px;margin-bottom:8px;'>"
|
| 3399 |
-
"<strong>Shortcuts:</strong> ArrowUp=Positive | ArrowDown=Negative | 1=Positive | 2=Negative | 3=Uncertain | 4=Skip
|
| 3400 |
"</div>"
|
| 3401 |
"<script>"
|
| 3402 |
"document.addEventListener('keydown', function(event) {"
|
| 3403 |
" if (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA') return;"
|
| 3404 |
" const key = event.key;"
|
| 3405 |
" let buttonText = null;"
|
| 3406 |
-
" if (key === 'ArrowUp' || key === '1') buttonText = '
|
| 3407 |
-
" else if (key === 'ArrowDown' || key === '2') buttonText = '
|
| 3408 |
" else if (key === '3') buttonText = 'Uncertain';"
|
| 3409 |
" else if (key === '4') buttonText = 'Skip';"
|
| 3410 |
-
" else if (key.toLowerCase() === 'r') buttonText = 'Reapply validation after conflict';"
|
| 3411 |
" if (!buttonText) return;"
|
| 3412 |
" event.preventDefault();"
|
| 3413 |
" const buttons = document.querySelectorAll('button');"
|
|
@@ -3450,7 +3486,7 @@ def create_app() -> gr.Blocks:
|
|
| 3450 |
return [], "", 1
|
| 3451 |
species_name = (species or "").strip()
|
| 3452 |
if not species_name:
|
| 3453 |
-
return [], "
|
| 3454 |
|
| 3455 |
rows, status_text, updated_page = _page_to_table(
|
| 3456 |
service=service_ref["queue"],
|
|
@@ -3512,18 +3548,18 @@ def create_app() -> gr.Blocks:
|
|
| 3512 |
|
| 3513 |
def refresh_for_selected_project(project_slug: str):
|
| 3514 |
if not project_slug:
|
| 3515 |
-
return gr.update(choices=[], value=None, interactive=False), [], "", 1, None, None, _spectrogram_title(None), _build_validation_summary_cards([]), gr.update(choices=["
|
| 3516 |
|
| 3517 |
species_options = _extract_species_options_from_queue(
|
| 3518 |
queue_service=service_ref["queue"],
|
| 3519 |
project_slug=project_slug,
|
| 3520 |
page_size=max(32, runtime_config.page_size),
|
| 3521 |
)
|
| 3522 |
-
corrected_choices = species_options + ["
|
| 3523 |
return (
|
| 3524 |
gr.update(choices=species_options, value=None, interactive=True),
|
| 3525 |
[],
|
| 3526 |
-
"
|
| 3527 |
1,
|
| 3528 |
None,
|
| 3529 |
None,
|
|
@@ -3661,7 +3697,7 @@ def create_app() -> gr.Blocks:
|
|
| 3661 |
detected_species: list[str],
|
| 3662 |
custom_by_project: dict[str, list[str]],
|
| 3663 |
):
|
| 3664 |
-
base_choices = list(dict.fromkeys([*detected_species, "
|
| 3665 |
value = (corrected_value or "").strip()
|
| 3666 |
|
| 3667 |
if not project_slug:
|
|
@@ -3684,7 +3720,7 @@ def create_app() -> gr.Blocks:
|
|
| 3684 |
):
|
| 3685 |
normalized_rows = _normalize_rows(rows)
|
| 3686 |
if not project_slug or not normalized_rows:
|
| 3687 |
-
return "
|
| 3688 |
|
| 3689 |
safe_idx = max(0, min(int(idx), len(normalized_rows) - 1))
|
| 3690 |
detection_key = str(normalized_rows[safe_idx][0]).strip()
|
|
@@ -3692,12 +3728,31 @@ def create_app() -> gr.Blocks:
|
|
| 3692 |
project_favs = set(updated_map.get(project_slug, []))
|
| 3693 |
if detection_key in project_favs:
|
| 3694 |
project_favs.remove(detection_key)
|
| 3695 |
-
action = "
|
|
|
|
| 3696 |
else:
|
| 3697 |
project_favs.add(detection_key)
|
| 3698 |
-
action = "
|
|
|
|
| 3699 |
updated_map[project_slug] = sorted(project_favs)
|
| 3700 |
-
return f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3701 |
|
| 3702 |
def on_table_select(project_slug: str, repo: str, rows: object, cache_key: str, session, evt: gr.SelectData):
|
| 3703 |
return _select_and_fetch_audio_with_title(
|
|
@@ -3800,35 +3855,35 @@ def create_app() -> gr.Blocks:
|
|
| 3800 |
),
|
| 3801 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3802 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3803 |
)
|
| 3804 |
|
| 3805 |
-
table.select(
|
| 3806 |
fn=on_table_select,
|
| 3807 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3808 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3809 |
)
|
| 3810 |
-
|
| 3811 |
-
|
| 3812 |
-
|
| 3813 |
-
|
| 3814 |
-
dataset_repo=repo,
|
| 3815 |
-
rows=rows,
|
| 3816 |
-
selected_index=int(idx),
|
| 3817 |
-
previous_cache_key=cache_key,
|
| 3818 |
-
allow_demo_fallback=False,
|
| 3819 |
-
hf_token=_project_fetch_token(project_slug, session),
|
| 3820 |
-
),
|
| 3821 |
-
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 3822 |
-
outputs=[audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3823 |
-
)
|
| 3824 |
-
clear_audio_btn.click(
|
| 3825 |
-
fn=lambda cache_key: (*_cleanup_selected_audio(audio_service=audio_service, cache_key=cache_key), None),
|
| 3826 |
-
inputs=[cache_key_state],
|
| 3827 |
-
outputs=[status, audio_player, spectrogram_image],
|
| 3828 |
).then(
|
| 3829 |
-
fn=
|
| 3830 |
-
inputs=
|
| 3831 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3832 |
)
|
| 3833 |
|
| 3834 |
refresh_event.then(
|
|
@@ -3846,6 +3901,14 @@ def create_app() -> gr.Blocks:
|
|
| 3846 |
),
|
| 3847 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3848 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3849 |
)
|
| 3850 |
next_event.then(
|
| 3851 |
fn=lambda rows: _build_validation_summary_cards(rows),
|
|
@@ -3862,6 +3925,14 @@ def create_app() -> gr.Blocks:
|
|
| 3862 |
),
|
| 3863 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3864 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3865 |
)
|
| 3866 |
prev_event.then(
|
| 3867 |
fn=lambda rows: _build_validation_summary_cards(rows),
|
|
@@ -3878,12 +3949,20 @@ def create_app() -> gr.Blocks:
|
|
| 3878 |
),
|
| 3879 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3880 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3881 |
)
|
| 3882 |
|
| 3883 |
favorite_btn.click(
|
| 3884 |
fn=toggle_favorite_detection,
|
| 3885 |
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3886 |
-
outputs=[status, favorite_detection_state],
|
| 3887 |
)
|
| 3888 |
|
| 3889 |
corrected_species_input.change(
|
|
@@ -4036,104 +4115,6 @@ def create_app() -> gr.Blocks:
|
|
| 4036 |
],
|
| 4037 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 4038 |
)
|
| 4039 |
-
reapply_event = reapply_btn.click(
|
| 4040 |
-
fn=lambda project_slug, rows, idx, pending_status, conflict_key, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value, only_conflicts: reapply_for_project(
|
| 4041 |
-
project_slug,
|
| 4042 |
-
rows,
|
| 4043 |
-
idx,
|
| 4044 |
-
pending_status,
|
| 4045 |
-
conflict_key,
|
| 4046 |
-
name,
|
| 4047 |
-
notes,
|
| 4048 |
-
cache_key,
|
| 4049 |
-
page,
|
| 4050 |
-
species,
|
| 4051 |
-
confidence,
|
| 4052 |
-
validator_filter_value,
|
| 4053 |
-
status_filter_value,
|
| 4054 |
-
updated_after_value,
|
| 4055 |
-
only_conflicts,
|
| 4056 |
-
),
|
| 4057 |
-
inputs=[
|
| 4058 |
-
selected_project_state,
|
| 4059 |
-
table,
|
| 4060 |
-
selected_index,
|
| 4061 |
-
pending_status_state,
|
| 4062 |
-
conflict_detection_key_state,
|
| 4063 |
-
validator_name,
|
| 4064 |
-
validation_notes,
|
| 4065 |
-
cache_key_state,
|
| 4066 |
-
page_state,
|
| 4067 |
-
species_filter,
|
| 4068 |
-
min_confidence,
|
| 4069 |
-
validator_filter,
|
| 4070 |
-
validation_status_filter,
|
| 4071 |
-
updated_after_filter,
|
| 4072 |
-
show_conflicts_only,
|
| 4073 |
-
],
|
| 4074 |
-
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 4075 |
-
)
|
| 4076 |
-
|
| 4077 |
-
batch_approve_event = batch_approve_conflicts_btn.click(
|
| 4078 |
-
fn=lambda project_slug, rows, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value: batch_for_project(
|
| 4079 |
-
project_slug,
|
| 4080 |
-
rows,
|
| 4081 |
-
"positive",
|
| 4082 |
-
name,
|
| 4083 |
-
notes,
|
| 4084 |
-
cache_key,
|
| 4085 |
-
page,
|
| 4086 |
-
species,
|
| 4087 |
-
confidence,
|
| 4088 |
-
validator_filter_value,
|
| 4089 |
-
status_filter_value,
|
| 4090 |
-
updated_after_value,
|
| 4091 |
-
),
|
| 4092 |
-
inputs=[
|
| 4093 |
-
selected_project_state,
|
| 4094 |
-
table,
|
| 4095 |
-
validator_name,
|
| 4096 |
-
validation_notes,
|
| 4097 |
-
cache_key_state,
|
| 4098 |
-
page_state,
|
| 4099 |
-
species_filter,
|
| 4100 |
-
min_confidence,
|
| 4101 |
-
validator_filter,
|
| 4102 |
-
validation_status_filter,
|
| 4103 |
-
updated_after_filter,
|
| 4104 |
-
],
|
| 4105 |
-
outputs=[status, cache_key_state, audio_player, table, page_state],
|
| 4106 |
-
)
|
| 4107 |
-
batch_reject_event = batch_reject_conflicts_btn.click(
|
| 4108 |
-
fn=lambda project_slug, rows, name, notes, cache_key, page, species, confidence, validator_filter_value, status_filter_value, updated_after_value: batch_for_project(
|
| 4109 |
-
project_slug,
|
| 4110 |
-
rows,
|
| 4111 |
-
"negative",
|
| 4112 |
-
name,
|
| 4113 |
-
notes,
|
| 4114 |
-
cache_key,
|
| 4115 |
-
page,
|
| 4116 |
-
species,
|
| 4117 |
-
confidence,
|
| 4118 |
-
validator_filter_value,
|
| 4119 |
-
status_filter_value,
|
| 4120 |
-
updated_after_value,
|
| 4121 |
-
),
|
| 4122 |
-
inputs=[
|
| 4123 |
-
selected_project_state,
|
| 4124 |
-
table,
|
| 4125 |
-
validator_name,
|
| 4126 |
-
validation_notes,
|
| 4127 |
-
cache_key_state,
|
| 4128 |
-
page_state,
|
| 4129 |
-
species_filter,
|
| 4130 |
-
min_confidence,
|
| 4131 |
-
validator_filter,
|
| 4132 |
-
validation_status_filter,
|
| 4133 |
-
updated_after_filter,
|
| 4134 |
-
],
|
| 4135 |
-
outputs=[status, cache_key_state, audio_player, table, page_state],
|
| 4136 |
-
)
|
| 4137 |
|
| 4138 |
approve_event.then(
|
| 4139 |
fn=lambda project_slug, repo, rows, idx, cache_key, session: _advance_to_next_row_with_title(
|
|
@@ -4147,6 +4128,14 @@ def create_app() -> gr.Blocks:
|
|
| 4147 |
),
|
| 4148 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4149 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4150 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4151 |
|
| 4152 |
reject_event.then(
|
|
@@ -4161,6 +4150,14 @@ def create_app() -> gr.Blocks:
|
|
| 4161 |
),
|
| 4162 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4163 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4164 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4165 |
|
| 4166 |
uncertain_event.then(
|
|
@@ -4175,6 +4172,14 @@ def create_app() -> gr.Blocks:
|
|
| 4175 |
),
|
| 4176 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4177 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4178 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4179 |
|
| 4180 |
skip_event.then(
|
|
@@ -4189,6 +4194,14 @@ def create_app() -> gr.Blocks:
|
|
| 4189 |
),
|
| 4190 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4191 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4192 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4193 |
|
| 4194 |
session_state.change(
|
|
@@ -4197,9 +4210,6 @@ def create_app() -> gr.Blocks:
|
|
| 4197 |
outputs=[validator_name],
|
| 4198 |
)
|
| 4199 |
|
| 4200 |
-
reapply_event.then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4201 |
-
batch_approve_event.then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4202 |
-
batch_reject_event.then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4203 |
report_btn.click(
|
| 4204 |
fn=build_report_for_project,
|
| 4205 |
inputs=[selected_project_state],
|
|
|
|
| 1271 |
|
| 1272 |
return (
|
| 1273 |
"<div style='display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:12px;margin:4px 0 12px 0;'>"
|
| 1274 |
+
f"<div style='padding:10px 14px;border-radius:10px;background:#ececec;'><div style='font-size:12px;color:#555;'>Total Items</div><div style='font-size:24px;font-weight:700;color:#222;'>{total}</div></div>"
|
| 1275 |
+
f"<div style='padding:10px 14px;border-radius:10px;background:#e7f4ea;'><div style='font-size:12px;color:#3f6c49;'>Positive</div><div style='font-size:24px;font-weight:700;color:#215d2f;'>{positive}</div></div>"
|
| 1276 |
+
f"<div style='padding:10px 14px;border-radius:10px;background:#fdeaea;'><div style='font-size:12px;color:#7b3a3a;'>Negative</div><div style='font-size:24px;font-weight:700;color:#6f1f1f;'>{negative}</div></div>"
|
| 1277 |
"</div>"
|
| 1278 |
)
|
| 1279 |
|
|
|
|
| 1336 |
return [list(item) for item in rows] if rows else []
|
| 1337 |
|
| 1338 |
|
| 1339 |
+
def _spectrogram_title(audio_name: str | None) -> str:
|
| 1340 |
+
if not audio_name:
|
| 1341 |
+
return "### Spectrogram"
|
| 1342 |
+
return f"### Spectrogram - {Path(audio_name).name}"
|
| 1343 |
+
|
| 1344 |
+
|
| 1345 |
+
def _selected_audio_display_name(rows: object, selected_index: int, audio_path: str | None) -> str | None:
|
| 1346 |
+
if audio_path:
|
| 1347 |
+
return Path(audio_path).name
|
| 1348 |
+
|
| 1349 |
+
normalized_rows = _normalize_rows(rows)
|
| 1350 |
+
if normalized_rows:
|
| 1351 |
+
safe_index = max(0, min(int(selected_index), len(normalized_rows) - 1))
|
| 1352 |
+
if len(normalized_rows[safe_index]) > 1:
|
| 1353 |
+
audio_id = str(normalized_rows[safe_index][1]).strip()
|
| 1354 |
+
if audio_id:
|
| 1355 |
+
return Path(audio_id).name
|
| 1356 |
+
return None
|
| 1357 |
+
|
| 1358 |
+
|
| 1359 |
+
def _mark_selected_row(rows: object, selected_index: int) -> list[list[object]]:
|
| 1360 |
+
normalized_rows = _normalize_rows(rows)
|
| 1361 |
+
if not normalized_rows:
|
| 1362 |
+
return []
|
| 1363 |
+
|
| 1364 |
+
safe_index = max(0, min(int(selected_index), len(normalized_rows) - 1))
|
| 1365 |
+
marked_rows: list[list[object]] = []
|
| 1366 |
+
for row_index, row in enumerate(normalized_rows):
|
| 1367 |
+
updated = list(row)
|
| 1368 |
+
if len(updated) > 2:
|
| 1369 |
+
species = str(updated[2])
|
| 1370 |
+
if species.startswith("▶ "):
|
| 1371 |
+
species = species[2:]
|
| 1372 |
+
if row_index == safe_index:
|
| 1373 |
+
species = f"▶ {species}"
|
| 1374 |
+
updated[2] = species
|
| 1375 |
+
marked_rows.append(updated)
|
| 1376 |
+
|
| 1377 |
+
return marked_rows
|
| 1378 |
|
| 1379 |
|
| 1380 |
def _paginate_rows(rows: list[list[object]], page: int, page_size: int) -> tuple[list[list[object]], int, int]:
|
|
|
|
| 1438 |
allow_demo_fallback=allow_demo_fallback,
|
| 1439 |
hf_token=hf_token,
|
| 1440 |
)
|
| 1441 |
+
display_name = _selected_audio_display_name(rows, selected_index, audio_path)
|
| 1442 |
+
return audio_path, cache_key, status, spectrogram_path, _spectrogram_title(display_name)
|
| 1443 |
|
| 1444 |
|
| 1445 |
def _select_and_fetch_audio_with_title(
|
|
|
|
| 1460 |
allow_demo_fallback=allow_demo_fallback,
|
| 1461 |
hf_token=hf_token,
|
| 1462 |
)
|
| 1463 |
+
display_name = _selected_audio_display_name(rows, selected_index, audio_path)
|
| 1464 |
return (
|
| 1465 |
selected_index,
|
| 1466 |
audio_path,
|
| 1467 |
updated_cache_key,
|
| 1468 |
status,
|
| 1469 |
spectrogram_path,
|
| 1470 |
+
_spectrogram_title(display_name),
|
| 1471 |
)
|
| 1472 |
|
| 1473 |
|
|
|
|
| 1487 |
allow_demo_fallback=allow_demo_fallback,
|
| 1488 |
hf_token=hf_token,
|
| 1489 |
)
|
| 1490 |
+
display_name = _selected_audio_display_name(rows, selected_index, audio_path)
|
| 1491 |
return (
|
| 1492 |
selected_index,
|
| 1493 |
audio_path,
|
| 1494 |
updated_cache_key,
|
| 1495 |
status,
|
| 1496 |
spectrogram_path,
|
| 1497 |
+
_spectrogram_title(display_name),
|
| 1498 |
)
|
| 1499 |
|
| 1500 |
|
|
|
|
| 1521 |
allow_demo_fallback=allow_demo_fallback,
|
| 1522 |
hf_token=hf_token,
|
| 1523 |
)
|
| 1524 |
+
display_name = _selected_audio_display_name(normalized_rows, safe_index, audio_path)
|
| 1525 |
+
return safe_index, audio_path, updated_cache_key, status, spectrogram_path, _spectrogram_title(display_name)
|
| 1526 |
|
| 1527 |
|
| 1528 |
def _cleanup_selected_audio(audio_service: _AudioServiceProtocol, cache_key: str) -> tuple[str, str | None]:
|
|
|
|
| 2470 |
validation_repository = AppendOnlyValidationRepository(base_dir=runtime_config.validation_base_dir)
|
| 2471 |
validation_service = ValidationService(validation_repository)
|
| 2472 |
|
| 2473 |
+
with gr.Blocks(title="BirdNET-Validator-App") as wrapper:
|
| 2474 |
+
gr.Markdown("# BirdNET-Validator-App")
|
| 2475 |
gr.Markdown("**Version with authentication, project-level authorization, and admin panel**")
|
| 2476 |
if bootstrap_warning:
|
| 2477 |
gr.Markdown(bootstrap_warning)
|
|
|
|
| 3093 |
return (
|
| 3094 |
gr.Dropdown(choices=[], value=None, interactive=False),
|
| 3095 |
(
|
| 3096 |
+
"ℹ️ **No projects available yet**\n\n"
|
| 3097 |
+
"To get started:\n"
|
| 3098 |
+
"1. Go to the **Admin** tab.\n"
|
| 3099 |
+
"2. Fill **New Project Slug**, **Project Name**, and **HF Dataset Repo ID**.\n"
|
| 3100 |
+
"3. Click **Create Project**.\n"
|
| 3101 |
+
"4. Go back to **Select Project** and choose the created project."
|
| 3102 |
),
|
| 3103 |
None,
|
| 3104 |
"",
|
|
|
|
| 3354 |
with gr.Column(scale=8):
|
| 3355 |
validation_summary_cards = gr.HTML(value=_build_validation_summary_cards([]))
|
| 3356 |
|
| 3357 |
+
spectrogram_title = gr.Markdown("### Spectrogram")
|
| 3358 |
spectrogram_image = gr.Image(
|
| 3359 |
label="",
|
| 3360 |
type="filepath",
|
| 3361 |
interactive=False,
|
| 3362 |
height=330,
|
| 3363 |
)
|
| 3364 |
+
with gr.Row():
|
| 3365 |
+
audio_player = gr.Audio(label="Selected Audio", type="filepath", autoplay=True)
|
| 3366 |
+
auto_play_audio = gr.Checkbox(label="Auto-play selected audio", value=True)
|
| 3367 |
|
| 3368 |
with gr.Row():
|
| 3369 |
+
approve_btn = gr.Button("Positive", variant="primary")
|
| 3370 |
+
reject_btn = gr.Button("Negative")
|
| 3371 |
uncertain_btn = gr.Button("Uncertain")
|
| 3372 |
skip_btn = gr.Button("Skip")
|
| 3373 |
+
favorite_btn = gr.Button("☆ Favorite", variant="secondary")
|
| 3374 |
|
| 3375 |
corrected_species_input = gr.Dropdown(
|
| 3376 |
+
label="Corrected species",
|
| 3377 |
+
choices=["Noise", "Undetermined"],
|
| 3378 |
allow_custom_value=True,
|
| 3379 |
filterable=True,
|
| 3380 |
value=None,
|
| 3381 |
)
|
| 3382 |
|
| 3383 |
+
status = gr.Textbox(label="Status", interactive=False)
|
| 3384 |
+
|
| 3385 |
table = gr.Dataframe(
|
| 3386 |
headers=[
|
| 3387 |
"detection_key",
|
|
|
|
| 3399 |
interactive=False,
|
| 3400 |
)
|
| 3401 |
selected_index = gr.Number(label="Selected row", value=0, precision=0, visible=False)
|
|
|
|
| 3402 |
|
| 3403 |
with gr.Column(scale=4):
|
| 3404 |
dataset_repo = gr.Textbox(label="Dataset repo", interactive=False)
|
| 3405 |
species_filter = gr.Dropdown(
|
| 3406 |
+
label="Species to validate",
|
| 3407 |
choices=[],
|
| 3408 |
value=None,
|
| 3409 |
interactive=False,
|
| 3410 |
)
|
| 3411 |
|
| 3412 |
+
gr.Markdown("#### Navigation")
|
| 3413 |
with gr.Row():
|
| 3414 |
+
prev_btn = gr.Button("←")
|
| 3415 |
+
next_btn = gr.Button("→")
|
|
|
|
| 3416 |
|
| 3417 |
+
gr.Markdown("#### Filters")
|
| 3418 |
min_confidence = gr.Slider(label="Minimum confidence", minimum=0.0, maximum=1.0, step=0.01, value=0.0)
|
| 3419 |
validator_filter = gr.Textbox(label="Validator filter", placeholder="Ex: validator-demo")
|
| 3420 |
validation_status_filter = gr.Dropdown(
|
|
|
|
| 3424 |
)
|
| 3425 |
updated_after_filter = gr.DateTime(label="Updated since", include_time=False, type="string")
|
| 3426 |
show_conflicts_only = gr.Checkbox(label="Show only conflicts", value=False)
|
| 3427 |
+
refresh_btn = gr.Button("Apply Filters")
|
| 3428 |
|
| 3429 |
+
gr.Markdown("#### Actions")
|
| 3430 |
validator_name = gr.Textbox(label="Validator", value="validator-demo")
|
| 3431 |
+
validation_notes = gr.Textbox(label="Notes", placeholder="Optional", lines=4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3432 |
report_btn = gr.Button("Generate validation report")
|
| 3433 |
|
| 3434 |
keyboard_shortcuts_info = gr.HTML(
|
| 3435 |
value="<div style='font-size:12px;color:#333;padding:8px 10px;background:#f5f5f5;border-radius:6px;margin-bottom:8px;'>"
|
| 3436 |
+
"<strong>Shortcuts:</strong> ArrowUp=Positive | ArrowDown=Negative | 1=Positive | 2=Negative | 3=Uncertain | 4=Skip"
|
| 3437 |
"</div>"
|
| 3438 |
"<script>"
|
| 3439 |
"document.addEventListener('keydown', function(event) {"
|
| 3440 |
" if (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA') return;"
|
| 3441 |
" const key = event.key;"
|
| 3442 |
" let buttonText = null;"
|
| 3443 |
+
" if (key === 'ArrowUp' || key === '1') buttonText = 'Positive';"
|
| 3444 |
+
" else if (key === 'ArrowDown' || key === '2') buttonText = 'Negative';"
|
| 3445 |
" else if (key === '3') buttonText = 'Uncertain';"
|
| 3446 |
" else if (key === '4') buttonText = 'Skip';"
|
|
|
|
| 3447 |
" if (!buttonText) return;"
|
| 3448 |
" event.preventDefault();"
|
| 3449 |
" const buttons = document.querySelectorAll('button');"
|
|
|
|
| 3486 |
return [], "", 1
|
| 3487 |
species_name = (species or "").strip()
|
| 3488 |
if not species_name:
|
| 3489 |
+
return [], "Select a species to start validation", 1
|
| 3490 |
|
| 3491 |
rows, status_text, updated_page = _page_to_table(
|
| 3492 |
service=service_ref["queue"],
|
|
|
|
| 3548 |
|
| 3549 |
def refresh_for_selected_project(project_slug: str):
|
| 3550 |
if not project_slug:
|
| 3551 |
+
return gr.update(choices=[], value=None, interactive=False), [], "", 1, None, None, _spectrogram_title(None), _build_validation_summary_cards([]), gr.update(choices=["Noise", "Undetermined"], value=None), []
|
| 3552 |
|
| 3553 |
species_options = _extract_species_options_from_queue(
|
| 3554 |
queue_service=service_ref["queue"],
|
| 3555 |
project_slug=project_slug,
|
| 3556 |
page_size=max(32, runtime_config.page_size),
|
| 3557 |
)
|
| 3558 |
+
corrected_choices = species_options + ["Noise", "Undetermined"]
|
| 3559 |
return (
|
| 3560 |
gr.update(choices=species_options, value=None, interactive=True),
|
| 3561 |
[],
|
| 3562 |
+
"Select a species to start validation",
|
| 3563 |
1,
|
| 3564 |
None,
|
| 3565 |
None,
|
|
|
|
| 3697 |
detected_species: list[str],
|
| 3698 |
custom_by_project: dict[str, list[str]],
|
| 3699 |
):
|
| 3700 |
+
base_choices = list(dict.fromkeys([*detected_species, "Noise", "Undetermined"]))
|
| 3701 |
value = (corrected_value or "").strip()
|
| 3702 |
|
| 3703 |
if not project_slug:
|
|
|
|
| 3720 |
):
|
| 3721 |
normalized_rows = _normalize_rows(rows)
|
| 3722 |
if not project_slug or not normalized_rows:
|
| 3723 |
+
return "No detection selected to favorite", favorite_map, gr.update(value="☆ Favorite", variant="secondary")
|
| 3724 |
|
| 3725 |
safe_idx = max(0, min(int(idx), len(normalized_rows) - 1))
|
| 3726 |
detection_key = str(normalized_rows[safe_idx][0]).strip()
|
|
|
|
| 3728 |
project_favs = set(updated_map.get(project_slug, []))
|
| 3729 |
if detection_key in project_favs:
|
| 3730 |
project_favs.remove(detection_key)
|
| 3731 |
+
action = "removed from favorites"
|
| 3732 |
+
button_update = gr.update(value="☆ Favorite", variant="secondary")
|
| 3733 |
else:
|
| 3734 |
project_favs.add(detection_key)
|
| 3735 |
+
action = "added to favorites"
|
| 3736 |
+
button_update = gr.update(value="★ Favorited", variant="primary")
|
| 3737 |
updated_map[project_slug] = sorted(project_favs)
|
| 3738 |
+
return f"Detection {detection_key} {action}", updated_map, button_update
|
| 3739 |
+
|
| 3740 |
+
def update_favorite_button_state(
|
| 3741 |
+
project_slug: str,
|
| 3742 |
+
rows: object,
|
| 3743 |
+
idx: int,
|
| 3744 |
+
favorite_map: dict[str, list[str]],
|
| 3745 |
+
):
|
| 3746 |
+
normalized_rows = _normalize_rows(rows)
|
| 3747 |
+
if not project_slug or not normalized_rows:
|
| 3748 |
+
return gr.update(value="☆ Favorite", variant="secondary")
|
| 3749 |
+
|
| 3750 |
+
safe_idx = max(0, min(int(idx), len(normalized_rows) - 1))
|
| 3751 |
+
detection_key = str(normalized_rows[safe_idx][0]).strip()
|
| 3752 |
+
favs = set((favorite_map or {}).get(project_slug, []))
|
| 3753 |
+
if detection_key in favs:
|
| 3754 |
+
return gr.update(value="★ Favorited", variant="primary")
|
| 3755 |
+
return gr.update(value="☆ Favorite", variant="secondary")
|
| 3756 |
|
| 3757 |
def on_table_select(project_slug: str, repo: str, rows: object, cache_key: str, session, evt: gr.SelectData):
|
| 3758 |
return _select_and_fetch_audio_with_title(
|
|
|
|
| 3855 |
),
|
| 3856 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3857 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3858 |
+
).then(
|
| 3859 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 3860 |
+
inputs=[table, selected_index],
|
| 3861 |
+
outputs=[table],
|
| 3862 |
+
).then(
|
| 3863 |
+
fn=update_favorite_button_state,
|
| 3864 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3865 |
+
outputs=[favorite_btn],
|
| 3866 |
)
|
| 3867 |
|
| 3868 |
+
table_select_event = table.select(
|
| 3869 |
fn=on_table_select,
|
| 3870 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3871 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3872 |
)
|
| 3873 |
+
table_select_event.then(
|
| 3874 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 3875 |
+
inputs=[table, selected_index],
|
| 3876 |
+
outputs=[table],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3877 |
).then(
|
| 3878 |
+
fn=update_favorite_button_state,
|
| 3879 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3880 |
+
outputs=[favorite_btn],
|
| 3881 |
+
)
|
| 3882 |
+
|
| 3883 |
+
auto_play_audio.change(
|
| 3884 |
+
fn=lambda enabled: gr.update(autoplay=bool(enabled)),
|
| 3885 |
+
inputs=[auto_play_audio],
|
| 3886 |
+
outputs=[audio_player],
|
| 3887 |
)
|
| 3888 |
|
| 3889 |
refresh_event.then(
|
|
|
|
| 3901 |
),
|
| 3902 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3903 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3904 |
+
).then(
|
| 3905 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 3906 |
+
inputs=[table, selected_index],
|
| 3907 |
+
outputs=[table],
|
| 3908 |
+
).then(
|
| 3909 |
+
fn=update_favorite_button_state,
|
| 3910 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3911 |
+
outputs=[favorite_btn],
|
| 3912 |
)
|
| 3913 |
next_event.then(
|
| 3914 |
fn=lambda rows: _build_validation_summary_cards(rows),
|
|
|
|
| 3925 |
),
|
| 3926 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3927 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3928 |
+
).then(
|
| 3929 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 3930 |
+
inputs=[table, selected_index],
|
| 3931 |
+
outputs=[table],
|
| 3932 |
+
).then(
|
| 3933 |
+
fn=update_favorite_button_state,
|
| 3934 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3935 |
+
outputs=[favorite_btn],
|
| 3936 |
)
|
| 3937 |
prev_event.then(
|
| 3938 |
fn=lambda rows: _build_validation_summary_cards(rows),
|
|
|
|
| 3949 |
),
|
| 3950 |
inputs=[selected_project_state, selected_dataset_repo_state, table, cache_key_state, session_state],
|
| 3951 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 3952 |
+
).then(
|
| 3953 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 3954 |
+
inputs=[table, selected_index],
|
| 3955 |
+
outputs=[table],
|
| 3956 |
+
).then(
|
| 3957 |
+
fn=update_favorite_button_state,
|
| 3958 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3959 |
+
outputs=[favorite_btn],
|
| 3960 |
)
|
| 3961 |
|
| 3962 |
favorite_btn.click(
|
| 3963 |
fn=toggle_favorite_detection,
|
| 3964 |
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 3965 |
+
outputs=[status, favorite_detection_state, favorite_btn],
|
| 3966 |
)
|
| 3967 |
|
| 3968 |
corrected_species_input.change(
|
|
|
|
| 4115 |
],
|
| 4116 |
outputs=[status, cache_key_state, audio_player, table, page_state, selected_index, pending_status_state, conflict_detection_key_state],
|
| 4117 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4118 |
|
| 4119 |
approve_event.then(
|
| 4120 |
fn=lambda project_slug, repo, rows, idx, cache_key, session: _advance_to_next_row_with_title(
|
|
|
|
| 4128 |
),
|
| 4129 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4130 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 4131 |
+
).then(
|
| 4132 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 4133 |
+
inputs=[table, selected_index],
|
| 4134 |
+
outputs=[table],
|
| 4135 |
+
).then(
|
| 4136 |
+
fn=update_favorite_button_state,
|
| 4137 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 4138 |
+
outputs=[favorite_btn],
|
| 4139 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4140 |
|
| 4141 |
reject_event.then(
|
|
|
|
| 4150 |
),
|
| 4151 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4152 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 4153 |
+
).then(
|
| 4154 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 4155 |
+
inputs=[table, selected_index],
|
| 4156 |
+
outputs=[table],
|
| 4157 |
+
).then(
|
| 4158 |
+
fn=update_favorite_button_state,
|
| 4159 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 4160 |
+
outputs=[favorite_btn],
|
| 4161 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4162 |
|
| 4163 |
uncertain_event.then(
|
|
|
|
| 4172 |
),
|
| 4173 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4174 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 4175 |
+
).then(
|
| 4176 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 4177 |
+
inputs=[table, selected_index],
|
| 4178 |
+
outputs=[table],
|
| 4179 |
+
).then(
|
| 4180 |
+
fn=update_favorite_button_state,
|
| 4181 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 4182 |
+
outputs=[favorite_btn],
|
| 4183 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4184 |
|
| 4185 |
skip_event.then(
|
|
|
|
| 4194 |
),
|
| 4195 |
inputs=[selected_project_state, selected_dataset_repo_state, table, selected_index, cache_key_state, session_state],
|
| 4196 |
outputs=[selected_index, audio_player, cache_key_state, status, spectrogram_image, spectrogram_title],
|
| 4197 |
+
).then(
|
| 4198 |
+
fn=lambda rows, idx: _mark_selected_row(rows, int(idx)),
|
| 4199 |
+
inputs=[table, selected_index],
|
| 4200 |
+
outputs=[table],
|
| 4201 |
+
).then(
|
| 4202 |
+
fn=update_favorite_button_state,
|
| 4203 |
+
inputs=[selected_project_state, table, selected_index, favorite_detection_state],
|
| 4204 |
+
outputs=[favorite_btn],
|
| 4205 |
).then(fn=lambda rows: _build_validation_summary_cards(rows), inputs=[table], outputs=[validation_summary_cards])
|
| 4206 |
|
| 4207 |
session_state.change(
|
|
|
|
| 4210 |
outputs=[validator_name],
|
| 4211 |
)
|
| 4212 |
|
|
|
|
|
|
|
|
|
|
| 4213 |
report_btn.click(
|
| 4214 |
fn=build_report_for_project,
|
| 4215 |
inputs=[selected_project_state],
|