Spaces:
Sleeping
Sleeping
Update pages/gpt.py
Browse files- pages/gpt.py +14 -2
pages/gpt.py
CHANGED
@@ -4,6 +4,14 @@ import torch
|
|
4 |
import textwrap
|
5 |
import plotly.express as px
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
st.header(':green[Text generation by GPT2 model]')
|
9 |
|
@@ -14,7 +22,7 @@ model = GPT2LMHeadModel.from_pretrained(
|
|
14 |
output_hidden_states = False,
|
15 |
)
|
16 |
|
17 |
-
model.load_state_dict(torch.load('
|
18 |
|
19 |
|
20 |
length = st.sidebar.slider('**Generated sequence length:**', 8, 256, 15)
|
@@ -58,4 +66,8 @@ if st.button('**Generate text**'):
|
|
58 |
st.write(textwrap.fill(tokenizer.decode(out_), 100))
|
59 |
st.image("pict/wow.png")
|
60 |
|
61 |
-
|
|
|
|
|
|
|
|
|
|
4 |
import textwrap
|
5 |
import plotly.express as px
|
6 |
|
7 |
+
from streamlit_extras.let_it_rain import rain
|
8 |
+
|
9 |
+
rain(
|
10 |
+
emoji="⭐",
|
11 |
+
font_size=54,
|
12 |
+
falling_speed=5,
|
13 |
+
animation_length="infinite",
|
14 |
+
)
|
15 |
|
16 |
st.header(':green[Text generation by GPT2 model]')
|
17 |
|
|
|
22 |
output_hidden_states = False,
|
23 |
)
|
24 |
|
25 |
+
model.load_state_dict(torch.load('model.pt', map_location=torch.device('cpu')))
|
26 |
|
27 |
|
28 |
length = st.sidebar.slider('**Generated sequence length:**', 8, 256, 15)
|
|
|
66 |
st.write(textwrap.fill(tokenizer.decode(out_), 100))
|
67 |
st.image("pict/wow.png")
|
68 |
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
|