danseith commited on
Commit
19d0d27
·
1 Parent(s): ba4ce98

don't allow deletions.

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -6,7 +6,7 @@ from transformers.pipelines import PIPELINE_REGISTRY, FillMaskPipeline
6
  from transformers import AutoModelForMaskedLM
7
 
8
  ex_str1 = "A crustless sandwich made from two slices of baked bread. The sandwich includes first and second matching " \
9
- "crustiess bread pieces. The bread pieces have the same general outer shape defined by an outer periphery " \
10
  "with central portions surrounded by an outer peripheral area, the bread pieces being at least partially " \
11
  "crimped together at the outer peripheral area."
12
 
@@ -149,6 +149,8 @@ def unmask(text, temp, rounds):
149
  idx = np.random.randint(0, len(score_list))
150
  score = score_list[idx]
151
  new_token = score_to_str[score]
 
 
152
  split_text[mask_pos] = new_token
153
  text = ' '.join(split_text)
154
  text = list(text)
@@ -166,6 +168,7 @@ demo = gr.Interface(
166
  inputs=[textbox, temp_slider, edit_slider],
167
  outputs=[output_textbox],
168
  examples=examples,
 
169
  )
170
 
171
  demo.launch()
 
6
  from transformers import AutoModelForMaskedLM
7
 
8
  ex_str1 = "A crustless sandwich made from two slices of baked bread. The sandwich includes first and second matching " \
9
+ "crustless bread pieces. The bread pieces have the same general outer shape defined by an outer periphery " \
10
  "with central portions surrounded by an outer peripheral area, the bread pieces being at least partially " \
11
  "crimped together at the outer peripheral area."
12
 
 
149
  idx = np.random.randint(0, len(score_list))
150
  score = score_list[idx]
151
  new_token = score_to_str[score]
152
+ if len(list(new_token)) < 2:
153
+ continue
154
  split_text[mask_pos] = new_token
155
  text = ' '.join(split_text)
156
  text = list(text)
 
168
  inputs=[textbox, temp_slider, edit_slider],
169
  outputs=[output_textbox],
170
  examples=examples,
171
+ allow_flagging='never'
172
  )
173
 
174
  demo.launch()