Einmalumdiewelt commited on
Commit
362371a
·
1 Parent(s): 7efbd03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -27,13 +27,13 @@ def summarize(inputs,model,summary_length):
27
  padding="max_length",
28
  return_tensors='pt').to(device)
29
  #generate preds
30
- preds = model.generate(**inputs,max_length=summary_length,min_length=30)
31
  #we decode the predictions to store them
32
  decoded_predictions = tokenizer.batch_decode(preds, skip_special_tokens=True)
33
  #return
34
  return decoded_predictions[0]
35
 
36
- description = "Quickly summarize your German text in a few sentences. \nThe algorithm was fine-tuned on high-quality German news articles."
37
 
38
  title = "Finally there's a German \ntext summarization algorithm."
39
 
@@ -45,17 +45,17 @@ examples = [["summarize: Maschinelles Lernen ist ein Oberbegriff für die „kü
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
 
27
  padding="max_length",
28
  return_tensors='pt').to(device)
29
  #generate preds
30
+ preds = model.generate(**inputs,max_length=summary_length+25,min_length=summary_length-25)
31
  #we decode the predictions to store them
32
  decoded_predictions = tokenizer.batch_decode(preds, skip_special_tokens=True)
33
  #return
34
  return decoded_predictions[0]
35
 
36
+ description = "Quickly summarize your German text in a few sentences. \nOur algorithms were fine-tuned on high-quality German news articles. Inference can take up to 60 seconds, so feel free to look at a few of the provided examples, first."
37
 
38
  title = "Finally there's a German \ntext summarization algorithm."
39
 
 
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.")
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 a preferred summary length (+/- 25 tokens).", value=100)
53
  # text output box
54
  out=gr.Textbox(lines=5, label="Here's your summary:")
55
 
56
  interface = gr.Interface(summarize,
57
  inputs=[
58
+ "summarize: " + txt,
59
  # Selection of models for inference
60
  drop,
61
  # Length of summaries