Spaces:
Build error
Build error
Commit
·
84e4d0d
1
Parent(s):
1388718
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import torch
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 5 |
|
| 6 |
|
| 7 |
-
def summarize(inputs,model
|
| 8 |
if model=="T5-base":
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("Einmalumdiewelt/T5-Base_GNAD")
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained("Einmalumdiewelt/T5-Base_GNAD")
|
|
@@ -43,17 +43,23 @@ examples = [["summarize: Maschinelles Lernen ist ein Oberbegriff für die „kü
|
|
| 43 |
# title=title,
|
| 44 |
# description=description,
|
| 45 |
# examples=examples)
|
|
|
|
|
|
|
| 46 |
txt=gr.Textbox(lines=15, label="I want to summarize this:", placeholder="Paste your German text in here. Don't forget to add the prefix \"summarize: \" for T5-base architecture.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
out=gr.Textbox(lines=5, label="Here's your summary:")
|
| 48 |
|
| 49 |
interface = gr.Interface(summarize,
|
| 50 |
inputs=[
|
| 51 |
txt,
|
| 52 |
# Selection of models for inference
|
| 53 |
-
|
| 54 |
# Length of summaries
|
| 55 |
-
|
| 56 |
-
],
|
| 57 |
# ouptut
|
| 58 |
outputs=out,
|
| 59 |
title=title,
|
|
|
|
| 4 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 5 |
|
| 6 |
|
| 7 |
+
def summarize(inputs,model,summary_length):
|
| 8 |
if model=="T5-base":
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("Einmalumdiewelt/T5-Base_GNAD")
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained("Einmalumdiewelt/T5-Base_GNAD")
|
|
|
|
| 43 |
# title=title,
|
| 44 |
# description=description,
|
| 45 |
# examples=examples)
|
| 46 |
+
|
| 47 |
+
# text input box
|
| 48 |
txt=gr.Textbox(lines=15, label="I want to summarize this:", placeholder="Paste your German text in here. Don't forget to add the prefix \"summarize: \" for T5-base architecture.")
|
| 49 |
+
# dropdown model selection
|
| 50 |
+
drop=gr.Dropdown(["T5-base", "Google pegasus", "Facebook bart-large"],label="Choose a fine-tuned architecture.")
|
| 51 |
+
# slider summary length selection
|
| 52 |
+
slide=gr.Slider(50, 250, step=50, label="Select preferred summary length.", value=150)
|
| 53 |
+
# text output box
|
| 54 |
out=gr.Textbox(lines=5, label="Here's your summary:")
|
| 55 |
|
| 56 |
interface = gr.Interface(summarize,
|
| 57 |
inputs=[
|
| 58 |
txt,
|
| 59 |
# Selection of models for inference
|
| 60 |
+
drop,
|
| 61 |
# Length of summaries
|
| 62 |
+
slide],
|
|
|
|
| 63 |
# ouptut
|
| 64 |
outputs=out,
|
| 65 |
title=title,
|