Spaces:
Sleeping
Sleeping
Fix layout and add args
Browse files- .gitignore +1 -0
- app.py +38 -35
.gitignore
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
.ipynb_checkpoints
|
2 |
.vscode
|
|
|
|
1 |
.ipynb_checkpoints
|
2 |
.vscode
|
3 |
+
*.pyc
|
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import nltk
|
2 |
import torch
|
3 |
import numpy as np
|
@@ -164,38 +166,39 @@ def inbertolate(doc: str,
|
|
164 |
|
165 |
|
166 |
if __name__ == '__main__':
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
1 |
+
import argparse
|
2 |
+
|
3 |
import nltk
|
4 |
import torch
|
5 |
import numpy as np
|
|
|
166 |
|
167 |
|
168 |
if __name__ == '__main__':
|
169 |
+
parser = argparse.ArgumentParser()
|
170 |
+
parser.add_argument('--port', type=int)
|
171 |
+
parser.add_argument('--server', type=int)
|
172 |
+
args = parser.parse_args()
|
173 |
+
|
174 |
+
demo = gr.Interface(
|
175 |
+
fn=inbertolate,
|
176 |
+
title="inBERTolate",
|
177 |
+
description=f"Hit your word count by using BERT ({pretrained}) to pad out your essays!",
|
178 |
+
inputs=[
|
179 |
+
gr.Textbox(label="Text", lines=10),
|
180 |
+
gr.Slider(label="Maximum length to insert between sentences",
|
181 |
+
minimum=1,
|
182 |
+
maximum=40,
|
183 |
+
step=1,
|
184 |
+
value=max_len),
|
185 |
+
gr.Slider(label="Top k", minimum=0, maximum=200, value=top_k),
|
186 |
+
gr.Slider(label="Temperature",
|
187 |
+
minimum=0,
|
188 |
+
maximum=2,
|
189 |
+
value=temperature),
|
190 |
+
gr.Slider(label="Typical p",
|
191 |
+
minimum=0,
|
192 |
+
maximum=1,
|
193 |
+
value=typical_p),
|
194 |
+
gr.Slider(label="Maximum iterations",
|
195 |
+
minimum=0,
|
196 |
+
maximum=1000,
|
197 |
+
value=max_iter),
|
198 |
+
gr.Slider(label="Burn-in",
|
199 |
+
minimum=0,
|
200 |
+
maximum=500,
|
201 |
+
value=burnin),
|
202 |
+
],
|
203 |
+
outputs=gr.Textbox(label="Expanded text", lines=30))
|
204 |
+
demo.launch(server_name=args.server or '0.0.0.0', server_port=args.port)
|