Akshay Vs commited on
Commit
3de099b
1 Parent(s): ccbaceb

Added functionality

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -9,7 +9,7 @@ st.markdown("<h1 style='text-align: center; color: white;'>Generate intresting s
9
  st.markdown('')
10
  st.markdown('')
11
 
12
- #initializing session_state
13
  os.system('pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu')
14
  os.system('pip install transformers')
15
 
@@ -17,7 +17,7 @@ from transformers import pipeline, set_seed
17
 
18
  generator = pipeline('text-generation', model='openai-gpt')
19
 
20
- def generate(initial_text, length=50, return_sequences=1):
21
  set_seed(randint(1,1000))
22
  result = generator(initial_text, max_length = length, num_return_sequences = return_sequences)
23
  return result[0]["generated_text"]
@@ -33,11 +33,14 @@ def type_text(text):
33
  #text = input("Enter something to begin with... ")
34
  #print(".\n.\n.\nGenerating\n.\n.\n.")
35
 
36
- for _ in range(10):
37
- result = generate(text)
38
- text=slice(result)
39
- st.title(result)
40
- #with concurrent.futures.ThreadPoolExecutor() as executor:
41
- # executor.submit(type_text, result.replace(text,""))
 
 
 
42
 
43
 
 
9
  st.markdown('')
10
  st.markdown('')
11
 
12
+ # initializing session_state
13
  os.system('pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu')
14
  os.system('pip install transformers')
15
 
 
17
 
18
  generator = pipeline('text-generation', model='openai-gpt')
19
 
20
+ def generate(initial_text, length=10, return_sequences=1):
21
  set_seed(randint(1,1000))
22
  result = generator(initial_text, max_length = length, num_return_sequences = return_sequences)
23
  return result[0]["generated_text"]
 
33
  #text = input("Enter something to begin with... ")
34
  #print(".\n.\n.\nGenerating\n.\n.\n.")
35
 
36
+ text = st.text_input('Enter something to begin with...', placeholder='I look at her, then i realised...', key="value")
37
+ st.write("Generating...")
38
+ if text:
39
+ for _ in range(50):
40
+ result = generate(text)
41
+ text=slice(result)
42
+ st.title(result.replace(text,""))
43
+ #with concurrent.futures.ThreadPoolExecutor() as executor:
44
+ # executor.submit(type_text, result.replace(text,""))
45
 
46