Spaces:
Sleeping
Sleeping
Commit
·
d2894f7
1
Parent(s):
d61cd07
first version
Browse files- app.py +22 -1
- requirements.txt +6 -0
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
4 |
+
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("liamvbetts/bart-large-cnn-v4")
|
6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("liamvbetts/bart-large-cnn-v4")
|
7 |
+
|
8 |
+
def summarize(article):
|
9 |
+
inputs = tokenizer(article, return_tensors="pt").input_ids
|
10 |
+
outputs = model.generate(inputs, max_new_tokens=128, do_sample=False)
|
11 |
+
summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return summary
|
13 |
+
|
14 |
+
# Create Gradio interface
|
15 |
+
input_text = gr.Textbox(lines=10, label="Input Text")
|
16 |
+
output_text = gr.Textbox(label="Summary")
|
17 |
+
|
18 |
+
gr.Interface(
|
19 |
+
fn=summarize,
|
20 |
+
inputs=input_text,
|
21 |
+
outputs=output_text,
|
22 |
+
title="News Summary App",
|
23 |
+
description="Enter a news text and get its summary."
|
24 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
datasets
|
4 |
+
evaluate
|
5 |
+
accelerate
|
6 |
+
torch
|