Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -69,7 +69,7 @@ out=grad.Textbox(lines=1, label="Generated Tensors")
|
|
69 |
grad.Interface(generate, inputs=txt, outputs=out).launch()
|
70 |
'''
|
71 |
|
72 |
-
|
73 |
from transformers import AutoModelWithLMHead, AutoTokenizer
|
74 |
import gradio as grad
|
75 |
|
@@ -91,3 +91,31 @@ context=grad.Textbox(lines=10, label="English", placeholder="Context")
|
|
91 |
ans=grad.Textbox(lines=1, label="Answer")
|
92 |
out=grad.Textbox(lines=1, label="Genereated Question")
|
93 |
grad.Interface(text2text, inputs=[context,ans], outputs=out).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
grad.Interface(generate, inputs=txt, outputs=out).launch()
|
70 |
'''
|
71 |
|
72 |
+
'''5.20
|
73 |
from transformers import AutoModelWithLMHead, AutoTokenizer
|
74 |
import gradio as grad
|
75 |
|
|
|
91 |
ans=grad.Textbox(lines=1, label="Answer")
|
92 |
out=grad.Textbox(lines=1, label="Genereated Question")
|
93 |
grad.Interface(text2text, inputs=[context,ans], outputs=out).launch()
|
94 |
+
'''
|
95 |
+
|
96 |
+
#5.21
|
97 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
98 |
+
import gradio as grad
|
99 |
+
text2text_tkn = AutoTokenizer.from_pretrained("deep-learning-analytics/wikihow-t5-small")
|
100 |
+
mdl = AutoModelWithLMHead.from_pretrained("deep-learning-analytics/wikihow-t5-small")
|
101 |
+
|
102 |
+
|
103 |
+
def text2text_summary(para):
|
104 |
+
initial_txt = para.strip().replace("\n","")
|
105 |
+
tkn_text = text2text_tkn.encode(initial_txt, return_tensors="pt")
|
106 |
+
|
107 |
+
tkn_ids = mdl.generate(
|
108 |
+
tkn_text,
|
109 |
+
max_length=250,
|
110 |
+
num_beams=5,
|
111 |
+
repetition_penalty=2.5,
|
112 |
+
|
113 |
+
early_stopping=True
|
114 |
+
)
|
115 |
+
|
116 |
+
response = text2text_tkn.decode(tkn_ids[0], skip_special_tokens=True)
|
117 |
+
return response
|
118 |
+
|
119 |
+
para=grad.Textbox(lines=10, label="Paragraph", placeholder="Copy paragraph")
|
120 |
+
out=grad.Textbox(lines=1, label="Summary")
|
121 |
+
grad.Interface(text2text_summary, inputs=para, outputs=out).launch()
|