Ilvir commited on
Commit
28582a2
·
1 Parent(s): 6287a05

Update pages/gpt.py

Browse files
Files changed (1) hide show
  1. pages/gpt.py +5 -42
pages/gpt.py CHANGED
@@ -4,46 +4,6 @@ import torch
4
  import textwrap
5
  import plotly.express as px
6
 
7
- # df = px.data.iris()
8
-
9
- # @st.cache_data
10
- # def get_img_as_base64(file):
11
- # with open(file, "rb") as f:
12
- # data = f.read()
13
- # return base64.b64encode(data).decode()
14
-
15
- # page_bg_img = f"""
16
- # <style>
17
- # [data-testid="stAppViewContainer"] > .main {{
18
- # background-image: url("https://i.pinimg.com/originals/9f/57/bd/9f57bd45d33eb906fdb3d7ffe22e2058.png");
19
- # background-size: 100%;
20
- # background-position: top left;
21
- # background-repeat: no-repeat;
22
- # background-attachment: local;
23
- # }}
24
- # # [data-testid="stSidebar"] > div:first-child {{
25
- # # background-image: url("https://catherineasquithgallery.com/uploads/posts/2021-02/1614542041_37-p-fon-belii-tekstura-43.jpg");
26
- # # background-size: 100%;
27
- # # background-position: center;
28
- # # background-repeat: no-repeat;
29
- # # background-attachment: fixed;
30
- # # }}
31
- # [data-testid="stHeader"] {{
32
- # background: rgba(0,0,0,0);
33
- # }}
34
- # [data-testid="stToolbar"] {{
35
- # right: 2rem;
36
- # }}
37
- # div.css-1n76uvr.esravye0 {{
38
- # background-color: rgba(238, 238, 238, 0.5);
39
- # border: 10px solid #EEEEEE;
40
- # padding: 5% 5% 5% 10%;
41
- # border-radius: 5px;
42
- # }}
43
- # </style>
44
- # """
45
-
46
- # st.markdown(page_bg_img, unsafe_allow_html=True)
47
 
48
  st.markdown('## Генерация текста GPT-моделью')
49
 
@@ -82,6 +42,9 @@ if st.button('Сгенерировать текст'):
82
  no_repeat_ngram_size=3,
83
  num_return_sequences=num_samples,
84
  ).cpu().numpy()
 
85
  for i, out_ in enumerate(out):
86
- st.write(f'Текст {i+1}:')
87
- st.write(textwrap.fill(tokenizer.decode(out_), 100))
 
 
 
4
  import textwrap
5
  import plotly.express as px
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  st.markdown('## Генерация текста GPT-моделью')
9
 
 
42
  no_repeat_ngram_size=3,
43
  num_return_sequences=num_samples,
44
  ).cpu().numpy()
45
+ st.write('**_Результат_** 👇')
46
  for i, out_ in enumerate(out):
47
+
48
+ with st.expander(f'Текст {i+1}:'):
49
+ st.write(textwrap.fill(tokenizer.decode(out_), 100))
50
+ st.image("pict/wow.png")