File size: 787 Bytes
dfaa329 2d8fe08 dfaa329 7050879 dfaa329 7050879 dfaa329 e781147 2d8fe08 7050879 dfaa329 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import streamlit as st
from transformers import pipeline, AutoModelForSeq2SeqLM
from peft import PeftModel, PeftConfig
# from pathlib import Path
st.title("Thai News Summarizer")
st.subheader("Thai News Summarizer")
text = st.text_area('News', '', height=200)
# st.write('This KHAW? -->', text)
peft_model_id = "Saltywan/mt5-base-lora-thaisum-news"
config = PeftConfig.from_pretrained(peft_model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path)
model = PeftModel.from_pretrained(model, peft_model_id)
summarizer = pipeline("summarization", model=model, tokenizer=config.base_model_name_or_path)
if st.button('Summarize'):
text = summarizer("summarize: " + text, max_length=256)
desired_text = text[0]['summary_text']
st.write(desired_text) |