import gradio as gr from transformers import pipeline import csv foo = "An" bar = None baz = "Example" fields = [foo, bar, baz] #hub_model_id = "huggingface-course/mt5-small-finetuned-amazon-en-es" model_id = "philschmid/bart-large-cnn-samsum" #model_id = "t5-base" summarizer = pipeline("summarization", model=model_id) def summarize(text): #return "Summary: " + text text = str(text) generated_summary = summarizer(text, max_length=150, min_length = 20) fields = [text, generated_summary] with open('input.csv','a', newline='') as f: writer = csv.writer(f) writer.writerow(fields) return "Summary: " + str(generated_summary) iface = gr.Interface(fn=summarize, inputs="text", outputs="text") iface.launch()