Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -524,6 +524,11 @@ def capture_selection(text, seqlen, current_ids, evt: gr.SelectData | None = Non
|
|
| 524 |
indices_csv = to_ranges(token_idxs)
|
| 525 |
return indices_csv, f"Selected chars [{start}:{end}) → tokens {indices_csv}"
|
| 526 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
def apply_noise(src, state_ids, seqlen, indices_csv, add_left, add_right, seed):
|
| 528 |
ensure_model(src)
|
| 529 |
tok = model_cache["tokenizer"]
|
|
@@ -623,11 +628,12 @@ with gr.Blocks(title="CNA — Interactive Denoising") as demo:
|
|
| 623 |
|
| 624 |
# “Noise Selection” just applies whatever is in indices_csv
|
| 625 |
btn_noise_selection.click(
|
| 626 |
-
|
| 627 |
-
[src, ids_state, seqlen, indices_csv,
|
| 628 |
[ids_state, current_text, status]
|
| 629 |
)
|
| 630 |
|
|
|
|
| 631 |
# Manual indices + prepend/append noise
|
| 632 |
btn_apply_noise.click(
|
| 633 |
apply_noise,
|
|
|
|
| 524 |
indices_csv = to_ranges(token_idxs)
|
| 525 |
return indices_csv, f"Selected chars [{start}:{end}) → tokens {indices_csv}"
|
| 526 |
|
| 527 |
+
def noise_selection(src, state_ids, seqlen, indices_csv, seed):
|
| 528 |
+
# Reuse apply_noise but force prepend/append noise to zero
|
| 529 |
+
return apply_noise(src, state_ids, seqlen, indices_csv, 0, 0, seed)
|
| 530 |
+
|
| 531 |
+
|
| 532 |
def apply_noise(src, state_ids, seqlen, indices_csv, add_left, add_right, seed):
|
| 533 |
ensure_model(src)
|
| 534 |
tok = model_cache["tokenizer"]
|
|
|
|
| 628 |
|
| 629 |
# “Noise Selection” just applies whatever is in indices_csv
|
| 630 |
btn_noise_selection.click(
|
| 631 |
+
noise_selection,
|
| 632 |
+
[src, ids_state, seqlen, indices_csv, seed],
|
| 633 |
[ids_state, current_text, status]
|
| 634 |
)
|
| 635 |
|
| 636 |
+
|
| 637 |
# Manual indices + prepend/append noise
|
| 638 |
btn_apply_noise.click(
|
| 639 |
apply_noise,
|