Spaces:
Build error
Build error
danseith
commited on
Commit
·
ba4ce98
1
Parent(s):
c16370c
Added longer examples.
Browse files
app.py
CHANGED
@@ -5,10 +5,23 @@ from transformers import pipeline
|
|
5 |
from transformers.pipelines import PIPELINE_REGISTRY, FillMaskPipeline
|
6 |
from transformers import AutoModelForMaskedLM
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def add_mask(text, size=1):
|
14 |
split_text = text.split()
|
@@ -138,17 +151,20 @@ def unmask(text, temp, rounds):
|
|
138 |
new_token = score_to_str[score]
|
139 |
split_text[mask_pos] = new_token
|
140 |
text = ' '.join(split_text)
|
141 |
-
|
|
|
|
|
|
|
142 |
|
143 |
-
textbox = gr.Textbox(label="
|
144 |
-
|
145 |
temp_slider = gr.Slider(1.0, 2.0, value=1.0, label='Creativity')
|
146 |
-
edit_slider = gr.Slider(1,
|
147 |
|
148 |
demo = gr.Interface(
|
149 |
fn=unmask,
|
150 |
inputs=[textbox, temp_slider, edit_slider],
|
151 |
-
outputs=[
|
152 |
examples=examples,
|
153 |
)
|
154 |
|
|
|
5 |
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 |
+
|
13 |
+
ex_str2 = "The present disclosure provides a DNA-targeting RNA that comprises a targeting sequence and, together with" \
|
14 |
+
" a modifying polypeptide, provides for site-specific modification of a target DNA and/or a polypeptide" \
|
15 |
+
" associated with the target DNA. "
|
16 |
+
|
17 |
+
ex_str3 = "The graphite plane is composed of a two-dimensional hexagonal lattice of carbon atoms and the plate has a " \
|
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, 50],
|
22 |
+
[ex_str2, 1.5, 10],
|
23 |
+
[ex_str3, 1.4, 20]]
|
24 |
+
|
25 |
|
26 |
def add_mask(text, size=1):
|
27 |
split_text = text.split()
|
|
|
151 |
new_token = score_to_str[score]
|
152 |
split_text[mask_pos] = new_token
|
153 |
text = ' '.join(split_text)
|
154 |
+
text = list(text)
|
155 |
+
text[0] = text[0].upper()
|
156 |
+
return ''.join(text)
|
157 |
+
|
158 |
|
159 |
+
textbox = gr.Textbox(label="Example prompts", lines=5)
|
160 |
+
output_textbox = gr.Textbox(placeholder="", lines=4)
|
161 |
temp_slider = gr.Slider(1.0, 2.0, value=1.0, label='Creativity')
|
162 |
+
edit_slider = gr.Slider(1, 150, step=5, value=1.0, label='Number of edits')
|
163 |
|
164 |
demo = gr.Interface(
|
165 |
fn=unmask,
|
166 |
inputs=[textbox, temp_slider, edit_slider],
|
167 |
+
outputs=[output_textbox],
|
168 |
examples=examples,
|
169 |
)
|
170 |
|