Spaces:
Runtime error
Runtime error
File size: 913 Bytes
4770a86 408f343 e61d618 4770a86 408f343 955d0d6 817f881 408f343 71d76cc e61d618 c6f8e5b f52aa82 e61d618 05ace25 c6f8e5b 408f343 4770a86 |
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 31 32 33 |
import gradio as gr
from transformers import pipeline
import csv
#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)
if text == "showdata":
lines = "(lines)"
with open('input.csv',"r") as f:
lines = f.readlines()
#print(lines)
return str(lines)
generated_summary = summarizer(text, max_length=80, min_length=20)[0]['summary_text']
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() |