Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
#text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
6 |
+
de_text_summary = pipeline("summarization", model="Shahm/bart-german")
|
7 |
+
#de_text_summary= pipeline("summarization", model="Joemgu/mlong-t5-large-sumstew")
|
8 |
+
|
9 |
+
def summary (input):
|
10 |
+
max_length = 1024 # adjust this value as needed
|
11 |
+
if len(input) > max_length:
|
12 |
+
input = input[:max_length]
|
13 |
+
output = de_text_summary(input)
|
14 |
+
return output[0]['summary_text']
|
15 |
+
|
16 |
+
gr.close_all()
|
17 |
+
|
18 |
+
# demo = gr.Interface(fn=summary, inputs="text",outputs="text")
|
19 |
+
demo = gr.Interface(fn=summary,
|
20 |
+
inputs=[gr.Textbox(label="Text eingeben, der zusammengefasst werden soll",lines=6)],
|
21 |
+
outputs=[gr.Textbox(label="Zusammengefasster Text",lines=4)],
|
22 |
+
title="Projekt 1: Text-Zusammenfassung",
|
23 |
+
description="DIESE ANWENDUNG WIRD ZUR ZUSAMMENFASSUNG DES TEXTES VERWENDET",
|
24 |
+
theme="default",
|
25 |
+
allow_flagging="never",
|
26 |
+
clear_btn="Bereinigen",
|
27 |
+
submit_btn="Übermitteln"
|
28 |
+
)
|
29 |
+
demo.launch()
|