Spaces:
Runtime error
Runtime error
Akshay Vs
commited on
Commit
•
ccbaceb
1
Parent(s):
6815209
Added functionality
Browse files
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 |
-
#
|
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=
|
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,21 +33,11 @@ def type_text(text):
|
|
33 |
#text = input("Enter something to begin with... ")
|
34 |
#print(".\n.\n.\nGenerating\n.\n.\n.")
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
#with concurrent.futures.ThreadPoolExecutor() as executor:
|
40 |
# executor.submit(type_text, result.replace(text,""))
|
41 |
|
42 |
-
|
43 |
-
text = st.text_input('Enter something to begin with...', placeholder='I look at her, then i realised', key="placeholder")
|
44 |
-
if text:
|
45 |
-
st.write("Generating...", text)
|
46 |
-
st.write("", text)
|
47 |
-
|
48 |
-
for _ in range(50):
|
49 |
-
result = generate(text)
|
50 |
-
text=slice(result)
|
51 |
-
st.write(text, text)
|
52 |
-
#with concurrent.futures.ThreadPoolExecutor() as executor:
|
53 |
-
# executor.submit(type_text, result.replace(text,""))
|
|
|
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=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 |
#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 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|