Spaces:
Build error
Build error
danseith
commited on
Commit
·
e20eecd
1
Parent(s):
19d0d27
Added sanity checking for successful iterations
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ ex_str3 = "The graphite plane is composed of a two-dimensional hexagonal lattice
|
|
18 |
"length and a width parallel to the graphite plane and a thickness orthogonal to the graphite plane with at " \
|
19 |
"least one of the length, width, and thickness values being 100 nanometers or smaller. "
|
20 |
|
21 |
-
examples = [[ex_str1, 1.2,
|
22 |
[ex_str2, 1.5, 10],
|
23 |
[ex_str3, 1.4, 20]]
|
24 |
|
@@ -134,8 +134,8 @@ scrambler = pipeline("temp-scale", model="anferico/bert-for-patents")
|
|
134 |
|
135 |
def unmask(text, temp, rounds):
|
136 |
sampling = 'multi'
|
137 |
-
|
138 |
-
for
|
139 |
text = add_mask(text, size=1)
|
140 |
split_text = text.split()
|
141 |
res = scrambler(text, temp=temp, top_k=10)
|
@@ -153,13 +153,14 @@ def unmask(text, temp, rounds):
|
|
153 |
continue
|
154 |
split_text[mask_pos] = new_token
|
155 |
text = ' '.join(split_text)
|
|
|
156 |
text = list(text)
|
157 |
text[0] = text[0].upper()
|
158 |
-
return ''.join(text)
|
159 |
|
160 |
|
161 |
textbox = gr.Textbox(label="Example prompts", lines=5)
|
162 |
-
output_textbox = gr.Textbox(placeholder="", lines=4)
|
163 |
temp_slider = gr.Slider(1.0, 2.0, value=1.0, label='Creativity')
|
164 |
edit_slider = gr.Slider(1, 150, step=5, value=1.0, label='Number of edits')
|
165 |
|
|
|
18 |
"length and a width parallel to the graphite plane and a thickness orthogonal to the graphite plane with at " \
|
19 |
"least one of the length, width, and thickness values being 100 nanometers or smaller. "
|
20 |
|
21 |
+
examples = [[ex_str1, 1.2, 1],
|
22 |
[ex_str2, 1.5, 10],
|
23 |
[ex_str3, 1.4, 20]]
|
24 |
|
|
|
134 |
|
135 |
def unmask(text, temp, rounds):
|
136 |
sampling = 'multi'
|
137 |
+
successful_iters = 0
|
138 |
+
for round in range(rounds):
|
139 |
text = add_mask(text, size=1)
|
140 |
split_text = text.split()
|
141 |
res = scrambler(text, temp=temp, top_k=10)
|
|
|
153 |
continue
|
154 |
split_text[mask_pos] = new_token
|
155 |
text = ' '.join(split_text)
|
156 |
+
successful_iters += 1
|
157 |
text = list(text)
|
158 |
text[0] = text[0].upper()
|
159 |
+
return ''.join(text) + str(successful_iters)
|
160 |
|
161 |
|
162 |
textbox = gr.Textbox(label="Example prompts", lines=5)
|
163 |
+
output_textbox = gr.Textbox(placeholder="Output will appear here", lines=4)
|
164 |
temp_slider = gr.Slider(1.0, 2.0, value=1.0, label='Creativity')
|
165 |
edit_slider = gr.Slider(1, 150, step=5, value=1.0, label='Number of edits')
|
166 |
|