Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,20 @@
|
|
| 1 |
-
from transformers import
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
| 5 |
-
summarizer = pipeline("summarization", model="paulowoicho/t5-podcast-summarisation", tokenizer="paulowoicho/t5-podcast-summarisation")
|
| 6 |
-
summary = summarizer(text, min_length=39, max_length=25000)
|
| 7 |
-
return summary[0]['summary_text']
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
model_name = "EleutherAI/gpt-3.5-turbo"
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def summarize_text(input_text):
|
| 7 |
+
# Load the tokenizer and model
|
| 8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 10 |
|
| 11 |
+
# Tokenize the input text
|
| 12 |
+
input_ids = tokenizer.encode(input_text, truncation=True, padding=True, return_tensors="pt")
|
| 13 |
|
| 14 |
+
# Generate the summary
|
| 15 |
+
summary_ids = model.generate(input_ids, max_length=150, num_beams=2, early_stopping=True)
|
| 16 |
+
summary = tokenizer.decode(summary_ids.squeeze(), skip_special_tokens=True)
|
| 17 |
+
|
| 18 |
+
return summary
|
| 19 |
+
|
| 20 |
+
gr.Interface(fn=summarize_text, inputs='text', outputs='text').launch()
|