Spaces:
Runtime error
Runtime error
File size: 977 Bytes
a885c80 0621dcf a885c80 0621dcf a885c80 |
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 27 28 29 30 |
# import gradio as gr
# gr.Interface.load("models/Abijith/Text-summarizer-t5-small").launch()
import os
import gradio as gr
from transformers import AutoTokenizer, T5ForConditionalGeneration
# Load model directly
tokenizer = AutoTokenizer.from_pretrained("Abijith/my_first_t5_billsum_model")
model = T5ForConditionalGeneration.from_pretrained("Abijith/my_first_t5_billsum_model")
def summarize_text(input_text):
summar_input = 'summarize: '+input_text
input_tokens = tokenizer(summar_input, return_tensors='pt').input_ids
outputs = model.generate(input_tokens)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Interface for the Gradio app
iface = gr.Interface(
fn=summarize_text,
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
outputs=gr.outputs.Textbox(label="Summary"),
title="Text Summarizer",
description="Enter a paragraph, and the app will provide a summary.",
)
# Launch the Gradio app
iface.launch()
|