Spaces:
Build error
Build error
jcarbonnell
commited on
Commit
•
056a08f
1
Parent(s):
37e3aef
Update app.py
Browse files
app.py
CHANGED
@@ -14,30 +14,29 @@ topics=["NFT", "Blockchain", "Metaverse"]
|
|
14 |
choice = st.sidebar.selectbox("Select one topic", topics)
|
15 |
|
16 |
if choice == 'NFT':
|
17 |
-
keywords=st.text_area("Input 4 keywords here: (optional)")
|
18 |
-
length=st.text_area("How long should be your text? (default: 512 words)")
|
19 |
|
20 |
-
if st.button("Generate"):
|
21 |
-
prompt = "<|startoftext|>"
|
22 |
-
generated = torch.tensor(tokenizer.encode(prompt)).unsqueeze(0)
|
23 |
-
generated = generated.to(device)
|
24 |
-
sample_outputs = model.generate(
|
25 |
-
generated,
|
26 |
-
do_sample=True,
|
27 |
-
top_k=50,
|
28 |
-
max_length = 512,
|
29 |
-
top_p=0.95,
|
30 |
-
num_return_sequences=1
|
31 |
-
)
|
32 |
-
for i, sample_output in enumerate(sample_outputs):
|
33 |
-
generated_text = tokenizer.decode(sample_output,
|
34 |
-
skip_special_tokens=True)
|
35 |
|
36 |
-
#st.text("Keywords: {}\n".format(keywords))
|
37 |
-
#st.text("Length in number of words: {}\n".format(length))
|
38 |
-
st.text("This is your tailored blog article {generated_text}")
|
39 |
-
summary = summarize(generated_text, num_sentences=1)
|
40 |
-
st.text("This is a tweet-sized summary of your article {summary}")
|
41 |
else:
|
42 |
-
st.write("Topic not available yet")
|
43 |
|
|
|
14 |
choice = st.sidebar.selectbox("Select one topic", topics)
|
15 |
|
16 |
if choice == 'NFT':
|
17 |
+
keywords=st.text_area("Input 4 keywords here: (optional)")
|
18 |
+
length=st.text_area("How long should be your text? (default: 512 words)")
|
19 |
|
20 |
+
if st.button("Generate"):
|
21 |
+
prompt = "<|startoftext|>"
|
22 |
+
generated = torch.tensor(tokenizer.encode(prompt)).unsqueeze(0)
|
23 |
+
generated = generated.to(device)
|
24 |
+
sample_outputs = model.generate(
|
25 |
+
generated,
|
26 |
+
do_sample=True,
|
27 |
+
top_k=50,
|
28 |
+
max_length = 512,
|
29 |
+
top_p=0.95,
|
30 |
+
num_return_sequences=1
|
31 |
+
)
|
32 |
+
for i, sample_output in enumerate(sample_outputs):
|
33 |
+
generated_text = tokenizer.decode(sample_output, skip_special_tokens=True)
|
|
|
34 |
|
35 |
+
#st.text("Keywords: {}\n".format(keywords))
|
36 |
+
#st.text("Length in number of words: {}\n".format(length))
|
37 |
+
st.text("This is your tailored blog article {generated_text}")
|
38 |
+
summary = summarize(generated_text, num_sentences=1)
|
39 |
+
st.text("This is a tweet-sized summary of your article {summary}")
|
40 |
else:
|
41 |
+
st.write("Topic not available yet")
|
42 |
|