Update pages/gpt.py
Browse files- pages/gpt.py +41 -0
pages/gpt.py
CHANGED
@@ -2,7 +2,48 @@ from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
|
2 |
import streamlit as st
|
3 |
import torch
|
4 |
import textwrap
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
st.markdown('## Генерация текста GPT-моделью')
|
8 |
|
|
|
2 |
import streamlit as st
|
3 |
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 |
|