Spaces:
Running
Running
aldan.creo
commited on
Commit
•
3b6b0ab
1
Parent(s):
02224ed
Update app
Browse files- app.py +55 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Gradio app with a big textbox for input and a big textbox for output.
|
3 |
+
Also show tho checkboxes for replace_chars and replace_spaces.
|
4 |
+
"""
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
from silver_speak.homoglyphs.random_attack import (
|
9 |
+
random_attack as random_homoglyphs_attack,
|
10 |
+
)
|
11 |
+
from silver_speak.deletion.random_attack import random_attack as random_deletion_attack
|
12 |
+
|
13 |
+
EXAMPLE_TEXT_1 = "Dr. Capy Cosmos, a capybara unlike any other, astounded the scientific community with his groundbreaking research in astrophysics. With his keen sense of observation and unparalleled ability to interpret cosmic data, he uncovered new insights into the mysteries of black holes and the origins of the universe. As he peered through telescopes with his large, round eyes, fellow researchers often remarked that it seemed as if the stars themselves whispered their secrets directly to him. Dr. Cosmos not only became a beacon of inspiration to aspiring scientists but also proved that intellect and innovation can be found in the most unexpected of creatures."
|
14 |
+
EXAMPLE_TEXT_2 = "What are the standards required of offered properties? Properties need to be habitable and must meet certain health and safety standards, which the local authority can discuss with you. These standards have been agreed by the Department of Housing, Local Government and Heritage. The local authority will assess your property to make sure it meets the standards. If the property does not meet the standards, the local authority will explain why and can discuss what could be done to bring the property up to standard. Some properties may not be suitable for all those in need of accommodation, due to location or other reasons. However, every effort will be made by the local authority to ensure that offered properties are matched to appropriate beneficiaries."
|
15 |
+
|
16 |
+
inputs = [
|
17 |
+
gr.Textbox(lines=10, label="Input text"),
|
18 |
+
gr.Checkbox(label="Homoglyphs", value=True),
|
19 |
+
gr.Slider(
|
20 |
+
minimum=0,
|
21 |
+
maximum=0.3,
|
22 |
+
step=0.01,
|
23 |
+
value=0.05,
|
24 |
+
label="Percentage of characters to replace",
|
25 |
+
),
|
26 |
+
gr.Checkbox(label="Zero-Width", value=False),
|
27 |
+
]
|
28 |
+
outputs = gr.Textbox(label="Output text", show_copy_button=True)
|
29 |
+
title = "Silverspeak"
|
30 |
+
description = "A tool to rewrite text to avoid AI detection systems."
|
31 |
+
|
32 |
+
|
33 |
+
def attack_fn(text, replace_chars, percentage, replace_spaces):
|
34 |
+
if replace_chars:
|
35 |
+
text = random_homoglyphs_attack(text=text, percentage=percentage)
|
36 |
+
if replace_spaces:
|
37 |
+
text = random_deletion_attack(original_text=text, percentage=percentage)
|
38 |
+
return text
|
39 |
+
|
40 |
+
|
41 |
+
gr.Interface(
|
42 |
+
fn=attack_fn,
|
43 |
+
inputs=inputs,
|
44 |
+
outputs=outputs,
|
45 |
+
title=title,
|
46 |
+
description=description,
|
47 |
+
allow_flagging="never",
|
48 |
+
examples=[
|
49 |
+
[EXAMPLE_TEXT_1, True, 0.05, False],
|
50 |
+
[EXAMPLE_TEXT_1, True, 0.03, True],
|
51 |
+
[EXAMPLE_TEXT_2, True, 0.1, False],
|
52 |
+
[EXAMPLE_TEXT_2, False, 0.05, True],
|
53 |
+
],
|
54 |
+
examples_per_page=2,
|
55 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
silver_speak @ git+https://github.com/ACMCMC/silverspeak.git@main
|
2 |
+
gradio==4.36.1
|