acmc commited on
Commit
df4edbd
·
verified ·
1 Parent(s): fdbf6e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -46,9 +46,9 @@ inputs = [
46
  label="Percentage of characters to replace",
47
  ),
48
  gr.Dropdown(
49
- value=[TypesOfHomoglyphs.IDENTICAL],
50
  multiselect=True,
51
- choices=[TypesOfHomoglyphs.IDENTICAL, TypesOfHomoglyphs.CONFUSABLES, TypesOfHomoglyphs.OCR_REFINED],
52
  label="Types of homoglyphs to use",
53
  ),
54
  gr.Checkbox(label="Zero-Width", value=False, visible=False),
@@ -61,7 +61,7 @@ For more information, please refer to the research paper: [Creo, Aldan and Shush
61
 
62
  def attack_fn(text, replace_chars, percentage, types_of_homoglyphs, replace_spaces):
63
  if replace_chars:
64
- text = random_homoglyphs_attack(text=text, percentage=percentage, types_of_homoglyphs_to_use=types_of_homoglyphs)
65
  if replace_spaces:
66
  text = random_deletion_attack(original_text=text, percentage=percentage)
67
  return text
@@ -96,7 +96,7 @@ gr.Interface(
96
  allow_flagging="never",
97
  theme=theme,
98
  examples=[
99
- [EXAMPLE_TEXT_1, True, 0.05, [TypesOfHomoglyphs.IDENTICAL]],
100
  # [EXAMPLE_TEXT_1, True, 0.05, [TypesOfHomoglyphs.IDENTICAL], False],
101
  # [EXAMPLE_TEXT_1, False, 0.05, [TypesOfHomoglyphs.IDENTICAL], True],
102
  # [EXAMPLE_TEXT_2, True, 0.1, [TypesOfHomoglyphs.IDENTICAL], False],
 
46
  label="Percentage of characters to replace",
47
  ),
48
  gr.Dropdown(
49
+ value=['identical'],
50
  multiselect=True,
51
+ choices=[x.value for x in TypesOfHomoglyphs],
52
  label="Types of homoglyphs to use",
53
  ),
54
  gr.Checkbox(label="Zero-Width", value=False, visible=False),
 
61
 
62
  def attack_fn(text, replace_chars, percentage, types_of_homoglyphs, replace_spaces):
63
  if replace_chars:
64
+ text = random_homoglyphs_attack(text=text, percentage=percentage, types_of_homoglyphs_to_use=[x for x in TypesOfHomoglyphs if x.value in types_of_homoglyphs])
65
  if replace_spaces:
66
  text = random_deletion_attack(original_text=text, percentage=percentage)
67
  return text
 
96
  allow_flagging="never",
97
  theme=theme,
98
  examples=[
99
+ [EXAMPLE_TEXT_1, True, 0.05, ['identical']],
100
  # [EXAMPLE_TEXT_1, True, 0.05, [TypesOfHomoglyphs.IDENTICAL], False],
101
  # [EXAMPLE_TEXT_1, False, 0.05, [TypesOfHomoglyphs.IDENTICAL], True],
102
  # [EXAMPLE_TEXT_2, True, 0.1, [TypesOfHomoglyphs.IDENTICAL], False],