teticio commited on
Commit
f40e7fa
1 Parent(s): a673aee

Fix layout and add args

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. 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
- block = gr.Blocks(css='.container')
168
- with block:
169
- gr.Markdown("<h1><center>inBERTolate</center></h1>")
170
- gr.Markdown(
171
- "<center>Hit your word count by using BERT to pad out your essays!</center>"
172
- )
173
- gr.Interface(
174
- fn=inbertolate,
175
- inputs=[
176
- gr.Textbox(label="Text", lines=10),
177
- gr.Slider(label="Maximum length to insert between sentences",
178
- minimum=1,
179
- maximum=40,
180
- step=1,
181
- value=max_len),
182
- gr.Slider(label="Top k", minimum=0, maximum=200, value=top_k),
183
- gr.Slider(label="Temperature",
184
- minimum=0,
185
- maximum=2,
186
- value=temperature),
187
- gr.Slider(label="Typical p",
188
- minimum=0,
189
- maximum=1,
190
- value=typical_p),
191
- gr.Slider(label="Maximum iterations",
192
- minimum=0,
193
- maximum=1000,
194
- value=max_iter),
195
- gr.Slider(label="Burn-in",
196
- minimum=0,
197
- maximum=500,
198
- value=burnin),
199
- ],
200
- outputs=gr.Textbox(label="Expanded text", lines=30))
201
- block.launch(server_name='0.0.0.0')
 
 
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)