jcarbonnell commited on
Commit
150d813
1 Parent(s): 8e20695

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -33
app.py CHANGED
@@ -6,40 +6,38 @@ model=GPT2LMHeadModel.from_pretrained("DemocracyStudio/generate_nft_content")
6
  tokenizer=GPT2Tokenizer.from_pretrained("DemocracyStudio/generate_nft_content")
7
  summarize=Summarizer()
8
 
9
- def main():
10
- st.title("Text generation for the marketing content of NFTs")
11
- st.subheader("Course project 'NLP with transformers' at opencampus.sh, Spring 2022")
12
 
13
- st.sidebar.image("bayc crown.png", use_column_width=True)
14
- topics=["NFT", "Blockchain", "Metaverse"]
15
- choice = st.sidebar.selectbox("Select one topic", topics)
16
 
17
- if choice == 'NFT':
18
- keywords=st.text_area("Input 4 keywords here: (optional)")
19
- length=st.text_area("How long should be your text? (default: 512 words)")
20
-
21
- if st.button("Generate"):
22
- prompt = "<|startoftext|>"
23
- generated = torch.tensor(tokenizer.encode(prompt)).unsqueeze(0)
24
- generated = generated.to(device)
25
- sample_outputs = model.generate(
26
- generated,
27
- do_sample=True,
28
- top_k=50,
29
- max_length = 512,
30
- top_p=0.95,
31
- num_return_sequences=1
32
- )
33
- for i, sample_output in enumerate(sample_outputs):
34
- generated_text = tokenizer.decode(sample_output,
35
- skip_special_tokens=True)
36
-
37
- st.text("Keywords: {}\n".format(keywords))
38
- st.text("Length in number of words: {}\n".format(length))
39
- st.text("This is your tailored blog article {generated_text}")
40
- summary = summarize(generated_text, num_sentences=1)
41
- st.text("This is a tweet-sized summary of your article {summary}")
42
 
43
- else:
44
- st.write("Topic not available yet")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
 
6
  tokenizer=GPT2Tokenizer.from_pretrained("DemocracyStudio/generate_nft_content")
7
  summarize=Summarizer()
8
 
9
+ st.title("Text generation for the marketing content of NFTs")
10
+ st.subheader("Course project 'NLP with transformers' at opencampus.sh, Spring 2022")
 
11
 
12
+ st.sidebar.image("bayc crown.png", use_column_width=True)
13
+ 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