UNIST-Eunchan commited on
Commit
e07cf78
β€’
1 Parent(s): fc5a865

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -2,13 +2,15 @@ import transformers
2
  import streamlit as st
3
 
4
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
 
 
 
 
5
 
6
  tokenizer = AutoTokenizer.from_pretrained("UNIST-Eunchan/bart-dnc-booksum")
7
 
8
- tokenizer = AutoTokenizer.from_pretrained("gpt2-large")
9
  @st.cache
10
  def load_model(model_name):
11
-
12
  model = AutoModelForSeq2SeqLM.from_pretrained("UNIST-Eunchan/bart-dnc-booksum")
13
  return model
14
 
@@ -29,14 +31,18 @@ def infer(input_ids, max_length, temperature, top_k, top_p):
29
  )
30
 
31
  return output_sequences
32
- default_value = "See how a modern neural network auto-completes your text πŸ€— This site, built by the Hugging Face team, lets you write a whole document directly from your browser, and you can trigger the Transformer anywhere using the Tab key. Its like having a smart machine that completes your thoughts πŸ˜€ Get started by typing a custom snippet, check out the repository, or try one of the examples. Have fun!"
 
 
 
 
33
 
34
  #prompts
35
- st.title("Write with Transformers πŸ¦„")
36
  st.write("The almighty king of text generation, GPT-2 comes in four available sizes, only three of which have been publicly made available. Feared for its fake news generation capabilities, it currently stands as the most syntactically coherent model. A direct successor to the original GPT, it reinforces the already established pre-training/fine-tuning killer duo. From the paper: Language Models are Unsupervised Multitask Learners by Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever.")
37
 
38
  sent = st.text_area("Text", default_value, height = 550)
39
- max_length = st.sidebar.slider("Max Length", min_value = 10, max_value=256)
40
  temperature = st.sidebar.slider("Temperature", value = 1.0, min_value = 0.0, max_value=1.0, step=0.05)
41
  top_k = st.sidebar.slider("Top-k", min_value = 0, max_value=5, value = 0)
42
  top_p = st.sidebar.slider("Top-p", min_value = 0.0, max_value=1.0, step = 0.05, value = 0.92)
 
2
  import streamlit as st
3
 
4
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
5
+ import json
6
+
7
+ with open('testbook.json') as f:
8
+ test_book = json.load(f)
9
 
10
  tokenizer = AutoTokenizer.from_pretrained("UNIST-Eunchan/bart-dnc-booksum")
11
 
 
12
  @st.cache
13
  def load_model(model_name):
 
14
  model = AutoModelForSeq2SeqLM.from_pretrained("UNIST-Eunchan/bart-dnc-booksum")
15
  return model
16
 
 
31
  )
32
 
33
  return output_sequences
34
+
35
+ default_value = test_book[0]['book']
36
+
37
+ '''
38
+ '''
39
 
40
  #prompts
41
+ st.title("Book Summarization πŸ“š")
42
  st.write("The almighty king of text generation, GPT-2 comes in four available sizes, only three of which have been publicly made available. Feared for its fake news generation capabilities, it currently stands as the most syntactically coherent model. A direct successor to the original GPT, it reinforces the already established pre-training/fine-tuning killer duo. From the paper: Language Models are Unsupervised Multitask Learners by Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei and Ilya Sutskever.")
43
 
44
  sent = st.text_area("Text", default_value, height = 550)
45
+ max_length = st.sidebar.slider("Max Length", value = 512,min_value = 10, max_value=1024)
46
  temperature = st.sidebar.slider("Temperature", value = 1.0, min_value = 0.0, max_value=1.0, step=0.05)
47
  top_k = st.sidebar.slider("Top-k", min_value = 0, max_value=5, value = 0)
48
  top_p = st.sidebar.slider("Top-p", min_value = 0.0, max_value=1.0, step = 0.05, value = 0.92)