|
import adagio |
|
from transformers import GPT2LMHeadModel, GPT2Tokenizer |
|
|
|
def app(): |
|
adagio.set_title("์๋ ์ผ๊ธฐ ์์ฑ๊ธฐ") |
|
|
|
keywords = adagio.text_input("5๊ฐ์ ํค์๋๋ฅผ ์
๋ ฅํ์ธ์ (์ผํ๋ก ๊ตฌ๋ถ)", "") |
|
keyword_list = [kw.strip() for kw in keywords.split(",")] |
|
|
|
if len(keyword_list) == 5 and adagio.button("์ผ๊ธฐ ์ฐ๊ธฐ"): |
|
|
|
model = GPT2LMHeadModel.from_pretrained("gpt2") |
|
tokenizer = GPT2Tokenizer.from_pretrained("gpt2") |
|
|
|
|
|
input_ids = tokenizer.encode(" ".join(keyword_list), return_tensors="pt") |
|
output = model.generate(input_ids, max_length=500, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95, num_beams=5) |
|
|
|
|
|
diary = tokenizer.decode(output[0], skip_special_tokens=True) |
|
adagio.write(diary) |
|
|
|
if __name__ == "__main__": |
|
adagio.run(app) |