File size: 1,328 Bytes
bf1f8a9
a53b512
e74190f
 
956c21a
b2dbdf9
956c21a
 
a3c688e
956c21a
a3c688e
135ed0a
e74190f
f849db5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbdd2e7
e74190f
a3c688e
fbdd2e7
 
 
 
2c5db94
 
a3c688e
 
 
 
 
 
7dd1a16
03bf3c0
 
 
f849db5
2e068ff
03bf3c0
fbdd2e7
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

import streamlit as st
import requests
import os 
import transformers
from transformers import AutoModelWithLMHead, AutoTokenizer, AutoModelForCausalLM, pipeline
from transformers import GPT2Tokenizer, GPT2Model

tokenizer = AutoTokenizer.from_pretrained("samroni/model_gpt")

model = AutoModelForCausalLM.from_pretrained("samroni/model_gpt")
pipe = pipeline('text2text-generation', model="samroni/model_gpt", tokenizer=tokenizer)

prompt = """
word: risk
poem using word: And then the day came,
when the risk
to remain tight
in a bud
was more painful
than the risk
it took
to blossom.
word: bird
poem using word: She sights a bird, she chuckles
She flattens, then she crawls
She runs without the look of feet
Her eyes increase to Balls.
word: """
examples = [["sungai"], ["malam"], ["pepohonan"],["meja"],["tertawa"]]


kata = st.text_input("isikan kata", 0)
b1 = st.button("generate", 0)
hasil = st.text_area("hasil", 0)

def puisi_generate(prompt):
    ouputs = pipe(prompt, 
                  num_beams=5, 
                  early_stopping=True, 
                  repetition_penalty=20.0, 
                  num_return_sequences=1)
    return ouputs[0]['generated_text']

if b1:
    with st.spinner("Generating code..."):
        # use threading
        puisi_generate(
            prompt=prompt,
            
        )