Spaces:
Runtime error
Runtime error
File size: 894 Bytes
7549352 8dded45 7549352 8dded45 7549352 8dded45 7549352 8dded45 7549352 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from transformers import AutoTokenizer, AutoModelWithLMHead
import gradio as gr
model_name = "deep-learning-analytics/wikihow-t5-small"
text2text_token = AutoTokenizer.from_pretrained(model_name)
model = AutoModelWithLMHead.from_pretrained(model_name)
def text2text_summary(para):
initial_text = para.strip().replace("\n","")
token_text = text2text_token.encode(initial_text, return_tensors="pt")
token_ids = model.generate(
token_text,
max_length=250,
num_beams=5,
repetition_penalty=2.5,
early_stopping=True
)
response = text2text_token.decode(token_ids[0], skip_special_tokens=True)
return response
# UX
in_para = gr.Textbox(lines=10, label="Paragraph", placeholder="Copy paragraph")
out = gr.Textbox(lines=1, label="Summary")
gr.Interface(text2text_summary, inputs=in_para, outputs=out).launch() |