|
""" |
|
baseline_interactive.py |
|
""" |
|
import gradio as gr |
|
from transformers import MBartForConditionalGeneration, MBartTokenizer |
|
from transformers import pipeline |
|
|
|
model_name = "momo/rsp-sum" |
|
model = MBartForConditionalGeneration.from_pretrained(model_name) |
|
tokenizer = MBartTokenizer.from_pretrained(model_name, src_lang="ko_KR", tgt_lang="ko_KR") |
|
|
|
|
|
|
|
def summarization(News, Summary): |
|
summarizer = pipeline("summarization", model=model, tokenizer=tokenizer) |
|
summarizer(News, min_length=50, max_length=150) |
|
|
|
for result in summarizer(News): |
|
print(result) |
|
return result |
|
|
|
if __name__ == '__main__': |
|
|
|
|
|
app = gr.Interface( |
|
fn=summarization, |
|
inputs=gr.inputs.Textbox(lines=10, label="News"), |
|
outputs=gr.outputs.Textbox(lines=10, label="Summary"), |
|
title="한국어 뉴스 요약 생성기", |
|
description="Korean News Summary Generator" |
|
) |
|
app.launch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|