Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
peter szemraj
commited on
Commit
•
1bc0267
1
Parent(s):
bf00efa
:lipstick: improve and condense UI
Browse files
app.py
CHANGED
@@ -163,56 +163,61 @@ if __name__ == "__main__":
|
|
163 |
|
164 |
gr.Markdown("## Load Inputs & Select Parameters")
|
165 |
gr.Markdown(
|
166 |
-
"Enter text below in the text area. The text will be summarized [using the selected parameters](https://huggingface.co/blog/how-to-generate). Optionally load an example
|
167 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
gr.Markdown("_The base model is less performant than the large model, but is faster and will accept up to 2048 words per input (Large model accepts up to 768)._")
|
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 |
-
label="Choose an Example",
|
200 |
-
)
|
201 |
-
load_examples_button = gr.Button(
|
202 |
-
"Load Example",
|
203 |
-
)
|
204 |
input_text = gr.Textbox(
|
205 |
lines=6,
|
206 |
label="input text",
|
207 |
placeholder="Enter text to summarize, the text will be cleaned and truncated on Spaces. Narrative, academic (both papers and lecture transcription), and article text work well. May take a bit to generate depending on the input text :)",
|
208 |
)
|
209 |
gr.Markdown("Upload your own file:")
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
216 |
|
217 |
gr.Markdown("---")
|
218 |
|
@@ -221,7 +226,10 @@ if __name__ == "__main__":
|
|
221 |
gr.Markdown(
|
222 |
"Summary generation should take approximately 1-2 minutes for most settings."
|
223 |
)
|
224 |
-
summarize_button = gr.Button(
|
|
|
|
|
|
|
225 |
|
226 |
output_text = gr.HTML("<p><em>Output will appear below:</em></p>")
|
227 |
gr.Markdown("### Summary Output")
|
|
|
163 |
|
164 |
gr.Markdown("## Load Inputs & Select Parameters")
|
165 |
gr.Markdown(
|
166 |
+
"Enter text below in the text area. The text will be summarized [using the selected parameters](https://huggingface.co/blog/how-to-generate). Optionally load an example below or upload a file."
|
167 |
)
|
168 |
+
with gr.Row():
|
169 |
+
model_size = gr.Radio(
|
170 |
+
choices=["base", "large"], label="model size", value="large"
|
171 |
+
)
|
172 |
+
num_beams = gr.Radio(
|
173 |
+
choices=[2, 3, 4],
|
174 |
+
label="num beams",
|
175 |
+
value=2,
|
176 |
+
)
|
177 |
gr.Markdown("_The base model is less performant than the large model, but is faster and will accept up to 2048 words per input (Large model accepts up to 768)._")
|
178 |
+
with gr.Row():
|
179 |
+
token_batch_length = gr.Radio(
|
180 |
+
choices=[512, 768, 1024],
|
181 |
+
label="token batch length",
|
182 |
+
value=512,
|
183 |
+
)
|
184 |
+
length_penalty = gr.inputs.Slider(
|
185 |
+
minimum=0.5, maximum=1.0, label="length penalty", default=0.7, step=0.05
|
186 |
+
)
|
187 |
+
with gr.Row():
|
188 |
+
repetition_penalty = gr.inputs.Slider(
|
189 |
+
minimum=1.0,
|
190 |
+
maximum=5.0,
|
191 |
+
label="repetition penalty",
|
192 |
+
default=3.5,
|
193 |
+
step=0.1,
|
194 |
+
)
|
195 |
+
no_repeat_ngram_size = gr.Radio(
|
196 |
+
choices=[2, 3, 4],
|
197 |
+
label="no repeat ngram size",
|
198 |
+
value=3,
|
199 |
+
)
|
200 |
+
with gr.Row():
|
201 |
+
example_name = gr.Dropdown(
|
202 |
+
list(name_to_path.keys()),
|
203 |
+
label="Choose an Example",
|
204 |
+
)
|
205 |
+
load_examples_button = gr.Button(
|
206 |
+
"Load Example",
|
207 |
+
)
|
|
|
|
|
|
|
|
|
|
|
208 |
input_text = gr.Textbox(
|
209 |
lines=6,
|
210 |
label="input text",
|
211 |
placeholder="Enter text to summarize, the text will be cleaned and truncated on Spaces. Narrative, academic (both papers and lecture transcription), and article text work well. May take a bit to generate depending on the input text :)",
|
212 |
)
|
213 |
gr.Markdown("Upload your own file:")
|
214 |
+
with gr.Row():
|
215 |
+
uploaded_file = gr.File(
|
216 |
+
label="Upload a text file",
|
217 |
+
file_count="single",
|
218 |
+
type="file",
|
219 |
+
)
|
220 |
+
load_file_button = gr.Button("Load Uploaded File")
|
221 |
|
222 |
gr.Markdown("---")
|
223 |
|
|
|
226 |
gr.Markdown(
|
227 |
"Summary generation should take approximately 1-2 minutes for most settings."
|
228 |
)
|
229 |
+
summarize_button = gr.Button(
|
230 |
+
"Summarize!",
|
231 |
+
variant="primary",
|
232 |
+
)
|
233 |
|
234 |
output_text = gr.HTML("<p><em>Output will appear below:</em></p>")
|
235 |
gr.Markdown("### Summary Output")
|