Spaces:
Build error
Build error
uploading two files..
Browse files- app.py +44 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
#loading the dataset
|
5 |
+
xsum_dataset = load_dataset(
|
6 |
+
"xsum",
|
7 |
+
version="1.2.0",
|
8 |
+
cache_dir='/Documents/Huggin_Face/data'
|
9 |
+
) # Note: We specify cache_dir to use predownloaded data.
|
10 |
+
xsum_dataset
|
11 |
+
# The printed representation of this object shows the `num_rows`
|
12 |
+
# of each dataset split.
|
13 |
+
|
14 |
+
summarizer = pipeline(
|
15 |
+
task="summarization",
|
16 |
+
model="t5-small",
|
17 |
+
min_length=20,
|
18 |
+
max_length=40,
|
19 |
+
truncation=True,
|
20 |
+
model_kwargs={"cache_dir": '/Documents/Huggin_Face/'},
|
21 |
+
) # Note: We specify cache_dir to use predownloaded models.
|
22 |
+
|
23 |
+
def input_func(input_text):
|
24 |
+
input_text = input("Enter the text you want to summarize: ")
|
25 |
+
|
26 |
+
# Generate the summary
|
27 |
+
summary = summarizer(input_text, max_length=10000, min_length=30, do_sample=False)[0]['summary_text']
|
28 |
+
|
29 |
+
bullet_points = summary.split(". ")
|
30 |
+
|
31 |
+
for point in bullet_points:
|
32 |
+
print(f"- {point}")
|
33 |
+
|
34 |
+
# Print the generated summary
|
35 |
+
return ("Summary:", summary)
|
36 |
+
|
37 |
+
|
38 |
+
iface = gr.Interface(fn = input_func,
|
39 |
+
inputs = [
|
40 |
+
gr.inputs.Textbox(lines=5, placeholder="Enter your text here...", label="input_text")],
|
41 |
+
outputs="text",
|
42 |
+
)
|
43 |
+
|
44 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
sacremoses==0.0.53
|
4 |
+
datasets
|
5 |
+
torch torchvision torchaudio
|