Spaces:
Runtime error
Runtime error
# 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.Textbox(lines=5, label="Input Text"), | |
outputs=gr.Textbox(label="Summary"), | |
title="Text Summarizer", | |
description="Enter a paragraph, and the app will provide a summary.", | |
) | |
# Launch the Gradio app | |
iface.launch() | |