PFEemp2024 commited on
Commit
acd3439
·
verified ·
1 Parent(s): 63775f2

adding iput box

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -197,8 +197,8 @@ if __name__ == "__main__":
197
  demo = gr.Blocks()
198
 
199
  with demo:
200
- gr.Markdown("<h1 align='center'>Reactive Perturbation Defocusing (Rapid) for Textual Adversarial Defense</h1>")
201
- gr.Markdown("<h3 align='center'>Clarifications</h2>")
202
  gr.Markdown("""
203
  - This demo has no mechanism to ensure the adversarial example will be correctly repaired by Rapid. The repair success rate is actually the performance reported in the paper.
204
  - The adversarial example and repaired adversarial example may be unnatural to read, while it is because the attackers usually generate unnatural perturbations. Rapid does not introduce additional unnatural perturbations.
@@ -209,7 +209,7 @@ if __name__ == "__main__":
209
  with gr.Group():
210
  with gr.Row():
211
  input_dataset = gr.Radio(
212
- choices=["SST2", "Amazon", "Yahoo", "AGNews10K"],
213
  value="SST2",
214
  label="Select a testing dataset and an adversarial attacker to generate an adversarial example.",
215
  )
@@ -218,22 +218,22 @@ if __name__ == "__main__":
218
  value="TextFooler",
219
  label="Choose an Adversarial Attacker for generating an adversarial example to attack the model.",
220
  )
221
- with gr.Group(visible=False):
222
 
223
  with gr.Row():
224
  input_sentence = gr.Textbox(
225
  placeholder="Input a natural example...",
226
  label="Alternatively, input a natural example and its original label (from above datasets) to generate an adversarial example.",
227
- visible=False
228
  )
229
  input_label = gr.Textbox(
230
  placeholder="Original label, (must be a integer, because we use digits to represent labels in training)",
231
  label="Original Label",
232
- visible=False
233
  )
234
  gr.Markdown(
235
  "<h3 align='center'>To input an example, please select a dataset which the example belongs to or resembles.</h2>",
236
- visible=False
237
  )
238
 
239
  msg_text = gr.Textbox(
 
197
  demo = gr.Blocks()
198
 
199
  with demo:
200
+ gr.Markdown("<h1 align='center'>Detection and Correction based on Word Importance Ranking</h1>")
201
+ gr.Markdown("<h2 align='center'>Clarifications</h2>")
202
  gr.Markdown("""
203
  - This demo has no mechanism to ensure the adversarial example will be correctly repaired by Rapid. The repair success rate is actually the performance reported in the paper.
204
  - The adversarial example and repaired adversarial example may be unnatural to read, while it is because the attackers usually generate unnatural perturbations. Rapid does not introduce additional unnatural perturbations.
 
209
  with gr.Group():
210
  with gr.Row():
211
  input_dataset = gr.Radio(
212
+ choices=["SST2", "IMDB", "MR", "AGNews10K"],
213
  value="SST2",
214
  label="Select a testing dataset and an adversarial attacker to generate an adversarial example.",
215
  )
 
218
  value="TextFooler",
219
  label="Choose an Adversarial Attacker for generating an adversarial example to attack the model.",
220
  )
221
+ with gr.Group(visible=True):
222
 
223
  with gr.Row():
224
  input_sentence = gr.Textbox(
225
  placeholder="Input a natural example...",
226
  label="Alternatively, input a natural example and its original label (from above datasets) to generate an adversarial example.",
227
+ visible=True
228
  )
229
  input_label = gr.Textbox(
230
  placeholder="Original label, (must be a integer, because we use digits to represent labels in training)",
231
  label="Original Label",
232
+ visible=True
233
  )
234
  gr.Markdown(
235
  "<h3 align='center'>To input an example, please select a dataset which the example belongs to or resembles.</h2>",
236
+ visible=True
237
  )
238
 
239
  msg_text = gr.Textbox(