Spaces:
Sleeping
Sleeping
Amitontheweb
commited on
Commit
•
baaf7fd
1
Parent(s):
e622c0e
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,13 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# coding: utf-8
|
3 |
-
|
4 |
-
# # Summarization - ahmedmbutt/PTS-Bart-Large-CNN - MIT license
|
5 |
-
|
6 |
-
# In[22]:
|
7 |
-
|
8 |
|
9 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
10 |
import torch
|
11 |
import gradio as gr
|
12 |
|
13 |
-
|
14 |
-
# In[34]:
|
15 |
-
|
16 |
-
|
17 |
# Load model directly
|
18 |
|
19 |
tokenizer = AutoTokenizer.from_pretrained("ahmedmbutt/PTS-Bart-Large-CNN")
|
20 |
model = AutoModelForSeq2SeqLM.from_pretrained("ahmedmbutt/PTS-Bart-Large-CNN")
|
21 |
|
22 |
-
|
23 |
-
# In[60]:
|
24 |
-
|
25 |
-
|
26 |
def summarize (text):
|
27 |
|
28 |
input_ids = tokenizer(text, return_tensors="pt").input_ids
|
@@ -40,8 +25,6 @@ def summarize (text):
|
|
40 |
return (output)
|
41 |
|
42 |
|
43 |
-
# In[74]:
|
44 |
-
|
45 |
|
46 |
iface = gr.Interface(fn=summarize,
|
47 |
inputs=[gr.Textbox(label="Paste text to summarize and hit 'Submit'.", lines=10)],
|
@@ -65,7 +48,7 @@ iface = gr.Interface(fn=summarize,
|
|
65 |
</div>
|
66 |
|
67 |
""",
|
68 |
-
flagging_mode='never',
|
69 |
examples= ["""What is driving food inflation higher?
|
70 |
A drought last year and an ongoing heat wave have significantly reduced the supplies of foods like pulses, vegetables, and cereals. Curbs on food exports and reducing tariffs on imports have had little effect. Although vegetable supplies generally decrease during the summer months, this year's decline is much more pronounced. Temperatures in nearly half of the country are soaring 4-9 degrees Celsius above normal, spoiling harvested and stored vegetables and hindering the planting of crops such as onions, tomatoes, eggplant and spinach."""],
|
71 |
cache_examples=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
import torch
|
4 |
import gradio as gr
|
5 |
|
|
|
|
|
|
|
|
|
6 |
# Load model directly
|
7 |
|
8 |
tokenizer = AutoTokenizer.from_pretrained("ahmedmbutt/PTS-Bart-Large-CNN")
|
9 |
model = AutoModelForSeq2SeqLM.from_pretrained("ahmedmbutt/PTS-Bart-Large-CNN")
|
10 |
|
|
|
|
|
|
|
|
|
11 |
def summarize (text):
|
12 |
|
13 |
input_ids = tokenizer(text, return_tensors="pt").input_ids
|
|
|
25 |
return (output)
|
26 |
|
27 |
|
|
|
|
|
28 |
|
29 |
iface = gr.Interface(fn=summarize,
|
30 |
inputs=[gr.Textbox(label="Paste text to summarize and hit 'Submit'.", lines=10)],
|
|
|
48 |
</div>
|
49 |
|
50 |
""",
|
51 |
+
# flagging_mode='never',
|
52 |
examples= ["""What is driving food inflation higher?
|
53 |
A drought last year and an ongoing heat wave have significantly reduced the supplies of foods like pulses, vegetables, and cereals. Curbs on food exports and reducing tariffs on imports have had little effect. Although vegetable supplies generally decrease during the summer months, this year's decline is much more pronounced. Temperatures in nearly half of the country are soaring 4-9 degrees Celsius above normal, spoiling harvested and stored vegetables and hindering the planting of crops such as onions, tomatoes, eggplant and spinach."""],
|
54 |
cache_examples=True,
|