Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline, T5Tokenizer, T5ForConditionalGeneration | |
| import os | |
| token = os.getenv("HF_TOKEN") | |
| tokenizer = T5Tokenizer.from_pretrained("sumedh/t5-base-amazonreviews", clean_up_tokenization_spaces=True) | |
| model = T5ForConditionalGeneration.from_pretrained("sumedh/t5-base-amazonreviews") | |
| summarizer = pipeline("summarization", model="sumedh/t5-base-amazonreviews") | |
| def texto_sum(text): | |
| summary = summarizer(text, do_sample=False) | |
| return summary[0]['summary_text'] | |
| demo = gr.Interface( | |
| fn=texto_sum, | |
| inputs=gr.Textbox(label="Texto a introducir:", placeholder="Introduce el texto a resumir aquí..."), | |
| outputs="text" | |
| ) | |
| demo.launch() |