Upload 9 files
Browse files- main.py +58 -0
- pages/.ipynb_checkpoints/Без названия-checkpoint.ipynb +6 -0
- pages/.ipynb_checkpoints/✨BERT-checkpoint.py +119 -0
- pages/.ipynb_checkpoints/✨first-checkpoint.py +127 -0
- pages/.ipynb_checkpoints/✨third-checkpoint.py +114 -0
- pages/Без названия.ipynb +371 -0
- pages/✨BERT.py +119 -0
- pages/✨first.py +127 -0
- pages/✨third.py +114 -0
main.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.set_page_config(layout="wide")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
video_html = """
|
| 7 |
+
<style>
|
| 8 |
+
|
| 9 |
+
#myVideo {
|
| 10 |
+
position: fixed;
|
| 11 |
+
right: 0;
|
| 12 |
+
bottom: 0;
|
| 13 |
+
min-width: 100%;
|
| 14 |
+
min-height: 100%;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.content {
|
| 18 |
+
position: relative; /* Изменено на position: relative; */
|
| 19 |
+
bottom: 0;
|
| 20 |
+
background: rgba(0, 0, 0, 0.5);
|
| 21 |
+
color: #f1f1f1;
|
| 22 |
+
width: 100%;
|
| 23 |
+
padding: 20px;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
[data-testid="stToolbar"] {
|
| 27 |
+
right: 2rem;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
div.css-d6uc01.e1tzin5v0 {
|
| 31 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 32 |
+
border: 10px solid #EEEEEE;
|
| 33 |
+
padding: 5% 5% 5% 10%;
|
| 34 |
+
border-radius: 5px;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
</style>
|
| 38 |
+
<video autoplay muted loop id="myVideo">
|
| 39 |
+
<source src="https://rr4---sn-gvnuxaxjvh-c35z.googlevideo.com/videoplayback?expire=1686269230&ei=zhiCZJXvB-P7zLUP3K6SeA&ip=5.182.110.165&id=o-AOMElUbQqPajhZX5aErHwivnMyjp6i6a4uDOp4L6B3c8&itag=399&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&spc=qEK7B7Pbxq1VUrzvbs7fHjl6u6WKTaCFFP3qRYtBLA&vprv=1&svpuc=1&mime=video%2Fmp4&ns=NXLw4J-BddEHxlAHSqJEAZAN&gir=yes&clen=198203522&dur=3609.999&lmt=1630799721330343&keepalive=yes&fexp=24007246,24350018,51000011&beids=24350018&c=WEB&txp=5432434&n=qTHryvAvH9uy7A&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgMOr2k93xnKlQJTWwD400i4MLLRM7EjtE5MegwNmDkqECIQDOrlXOzYVXJZHHUG4jKkur9BYeQZWVRvj8kF0zse7jEg%3D%3D&redirect_counter=1&rm=sn-vgqee776&req_id=9fc7062719efa3ee&cms_redirect=yes&cmsv=e&ipbypass=yes&mh=D8&mip=5.228.41.215&mm=31&mn=sn-gvnuxaxjvh-c35z&ms=au&mt=1686247277&mv=m&mvi=4&pcm2cms=yes&pl=21&lsparams=ipbypass,mh,mip,mm,mn,ms,mv,mvi,pcm2cms,pl&lsig=AG3C_xAwRQIgTj1QLulfeB4eyrjf3vVnn4YAhZgSSDckaKESfmGwLh0CIQCDhcJaLoz9B45N-6cBAS52R3k9vbyeQsDTjhIAAtWA0w%3D%3D")>
|
| 40 |
+
Your browser does not support HTML5 video.
|
| 41 |
+
</video>
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
st.markdown(video_html, unsafe_allow_html=True)
|
| 45 |
+
|
| 46 |
+
col1, col2, col3 = st.columns([3,5,2])
|
| 47 |
+
|
| 48 |
+
with col2:
|
| 49 |
+
st.title('✨NLP Project by GPT-Team✨')
|
| 50 |
+
|
| 51 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 52 |
+
|
| 53 |
+
with col2:
|
| 54 |
+
st.markdown("<div style='text-align: center; font-size: 30px;'>Team members:</div>", unsafe_allow_html=True)
|
| 55 |
+
st.markdown("<div style='text-align: center; font-size: 25px;'>✨ Maria K. ✨ Osana B.</div>", unsafe_allow_html=True)
|
| 56 |
+
st.markdown("<div style='text-align: center; font-size: 25px;'>✨ Veronika K. ✨ Anna S.</div>", unsafe_allow_html=True)
|
| 57 |
+
st.markdown("<div style='text-align: center; font-size: 25px;'></div>", unsafe_allow_html=True)
|
| 58 |
+
st.markdown("<div style='text-align: center; font-size: 25px;'></div>", unsafe_allow_html=True)
|
pages/.ipynb_checkpoints/Без названия-checkpoint.ipynb
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [],
|
| 3 |
+
"metadata": {},
|
| 4 |
+
"nbformat": 4,
|
| 5 |
+
"nbformat_minor": 5
|
| 6 |
+
}
|
pages/.ipynb_checkpoints/✨BERT-checkpoint.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
|
| 6 |
+
df = px.data.iris()
|
| 7 |
+
|
| 8 |
+
@st.cache_data
|
| 9 |
+
def get_img_as_base64(file):
|
| 10 |
+
with open(file, "rb") as f:
|
| 11 |
+
data = f.read()
|
| 12 |
+
return base64.b64encode(data).decode()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
page_bg_img = f"""
|
| 16 |
+
<style>
|
| 17 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 18 |
+
background-image: url("https://i.ibb.co/kH8bcr4/1368432.jpg");
|
| 19 |
+
background-size: 115%;
|
| 20 |
+
background-position: top left;
|
| 21 |
+
background-repeat: no-repeat;
|
| 22 |
+
background-attachment: local;
|
| 23 |
+
}}
|
| 24 |
+
|
| 25 |
+
[data-testid="stSidebar"] > div:first-child {{
|
| 26 |
+
background-image: url("https://ibb.co/ZBkdJRg");
|
| 27 |
+
background-size: 115%;
|
| 28 |
+
background-position: center;
|
| 29 |
+
background-repeat: no-repeat;
|
| 30 |
+
background-attachment: fixed;
|
| 31 |
+
}}
|
| 32 |
+
|
| 33 |
+
[data-testid="stHeader"] {{
|
| 34 |
+
background: rgba(0,0,0,0);
|
| 35 |
+
}}
|
| 36 |
+
|
| 37 |
+
[data-testid="stToolbar"] {{
|
| 38 |
+
right: 2rem;
|
| 39 |
+
}}
|
| 40 |
+
|
| 41 |
+
div.css-1n76uvr.e1tzin5v0 {{
|
| 42 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 43 |
+
border: 10px solid #EEEEEE;
|
| 44 |
+
padding: 5% 5% 5% 10%;
|
| 45 |
+
border-radius: 5px;
|
| 46 |
+
}}
|
| 47 |
+
|
| 48 |
+
</style>
|
| 49 |
+
"""
|
| 50 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 51 |
+
|
| 52 |
+
import tensorflow as tf
|
| 53 |
+
from tensorflow import keras
|
| 54 |
+
import numpy as np
|
| 55 |
+
import matplotlib.pyplot as plt
|
| 56 |
+
|
| 57 |
+
################################################################################################
|
| 58 |
+
import torch
|
| 59 |
+
import numpy as np
|
| 60 |
+
import transformers
|
| 61 |
+
import pickle
|
| 62 |
+
from sklearn.linear_model import LogisticRegression
|
| 63 |
+
|
| 64 |
+
#def load_model():
|
| 65 |
+
model = transformers.DistilBertModel.from_pretrained(
|
| 66 |
+
"distilbert-base-uncased",
|
| 67 |
+
output_attentions = False,
|
| 68 |
+
output_hidden_states = False
|
| 69 |
+
)
|
| 70 |
+
#model.load_state_dict(torch.load('model/modelbert.pt', map_location=torch.device('cpu')))
|
| 71 |
+
tokenizer = transformers.DistilBertTokenizer.from_pretrained("distilbert-base-uncased")
|
| 72 |
+
#return model_finetuned, tokenizer
|
| 73 |
+
|
| 74 |
+
def preprocess_text(text_input, max_len, tokenizer):
|
| 75 |
+
input_tokens = tokenizer(
|
| 76 |
+
text_input,
|
| 77 |
+
return_tensors='pt',
|
| 78 |
+
padding=True,
|
| 79 |
+
max_length=max_len,
|
| 80 |
+
truncation = True
|
| 81 |
+
)
|
| 82 |
+
return input_tokens
|
| 83 |
+
|
| 84 |
+
def predict_sentiment(model, input_tokens):
|
| 85 |
+
#st.write(input_tokens)
|
| 86 |
+
ans = {0: "NEGATIVE", 1: "POSITIVE"}
|
| 87 |
+
last_hidden_states = model(**input_tokens)
|
| 88 |
+
#st.write('last_hidden_states ok')
|
| 89 |
+
vectors = last_hidden_states[0][:,0,:].detach().cpu().numpy()
|
| 90 |
+
#st.write('vectors ok')
|
| 91 |
+
#output = model(**input_tokens).last_hidden_states.detach().numpy()
|
| 92 |
+
with open('model/modelbert1.pkl', 'rb') as file:
|
| 93 |
+
cls = pickle.load(file)
|
| 94 |
+
result = ans[cls.predict(vectors)[0]]
|
| 95 |
+
return result
|
| 96 |
+
|
| 97 |
+
col1, col2, col3 = st.columns([1,5,1])
|
| 98 |
+
with col2:
|
| 99 |
+
|
| 100 |
+
st.title('Text sentiment analysis')
|
| 101 |
+
|
| 102 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 103 |
+
with col2:
|
| 104 |
+
|
| 105 |
+
max_len = st.slider('Maximum word length', 0, 500, 250)
|
| 106 |
+
|
| 107 |
+
text_input = st.text_input("Enter some text")
|
| 108 |
+
#model, tokenizer = load_model()
|
| 109 |
+
|
| 110 |
+
if text_input:
|
| 111 |
+
input_tokens = preprocess_text(text_input, max_len, tokenizer)
|
| 112 |
+
output = predict_sentiment(model, input_tokens)
|
| 113 |
+
st.write(output)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
################################################################################################
|
| 118 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
| 119 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
pages/.ipynb_checkpoints/✨first-checkpoint.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
|
| 6 |
+
df = px.data.iris()
|
| 7 |
+
|
| 8 |
+
@st.cache_data
|
| 9 |
+
def get_img_as_base64(file):
|
| 10 |
+
with open(file, "rb") as f:
|
| 11 |
+
data = f.read()
|
| 12 |
+
return base64.b64encode(data).decode()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
page_bg_img = f"""
|
| 16 |
+
<style>
|
| 17 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 18 |
+
background-image: url("https://wallpapercave.com/wp/wp6480460.jpg");
|
| 19 |
+
background-size: 115%;
|
| 20 |
+
background-position: top left;
|
| 21 |
+
background-repeat: no-repeat;
|
| 22 |
+
background-attachment: local;
|
| 23 |
+
}}
|
| 24 |
+
|
| 25 |
+
[data-testid="stSidebar"] > div:first-child {{
|
| 26 |
+
background-image: url("https://ibb.co/ZBkdJRg");
|
| 27 |
+
background-size: 115%;
|
| 28 |
+
background-position: center;
|
| 29 |
+
background-repeat: no-repeat;
|
| 30 |
+
background-attachment: fixed;
|
| 31 |
+
}}
|
| 32 |
+
|
| 33 |
+
[data-testid="stHeader"] {{
|
| 34 |
+
background: rgba(0,0,0,0);
|
| 35 |
+
}}
|
| 36 |
+
|
| 37 |
+
[data-testid="stToolbar"] {{
|
| 38 |
+
right: 2rem;
|
| 39 |
+
}}
|
| 40 |
+
|
| 41 |
+
div.css-1n76uvr.e1tzin5v0 {{
|
| 42 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 43 |
+
border: 10px solid #EEEEEE;
|
| 44 |
+
padding: 5% 5% 5% 10%;
|
| 45 |
+
border-radius: 5px;
|
| 46 |
+
}}
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
</style>
|
| 50 |
+
"""
|
| 51 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 52 |
+
|
| 53 |
+
import tensorflow as tf
|
| 54 |
+
from tensorflow import keras
|
| 55 |
+
import numpy as np
|
| 56 |
+
import matplotlib.pyplot as plt
|
| 57 |
+
|
| 58 |
+
################################################################################################
|
| 59 |
+
#Тут нужно будет добаить модель. Ниже пример:
|
| 60 |
+
|
| 61 |
+
# # Загрузка модели
|
| 62 |
+
# model = keras.models.load_model('cgan_model.h5')
|
| 63 |
+
|
| 64 |
+
# # Задание размерностей входных данных модели
|
| 65 |
+
# latent_dim = 128
|
| 66 |
+
# num_classes = 10
|
| 67 |
+
|
| 68 |
+
# # Функция для генерации изображения
|
| 69 |
+
# def generate_image(number):
|
| 70 |
+
# random_latent_vector = tf.random.normal(shape=(1, latent_dim))
|
| 71 |
+
# one_hot_label = tf.one_hot([number], num_classes)
|
| 72 |
+
# input_data = tf.concat([random_latent_vector, one_hot_label], axis=1)
|
| 73 |
+
|
| 74 |
+
# generated_image = model.predict(input_data)
|
| 75 |
+
# generated_image = generated_image.reshape(28, 28)
|
| 76 |
+
# generated_image = tf.image.resize(generated_image[None, ...], (28, 28))[0] # Добавлено [None, ...] для добавления измерения
|
| 77 |
+
# return generated_image
|
| 78 |
+
|
| 79 |
+
################################################################################################
|
| 80 |
+
|
| 81 |
+
#Оформление
|
| 82 |
+
|
| 83 |
+
col1, col2, col3 = st.columns([1,5,1])
|
| 84 |
+
with col2:
|
| 85 |
+
|
| 86 |
+
st.title('Название модели')
|
| 87 |
+
|
| 88 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 89 |
+
with col2:
|
| 90 |
+
|
| 91 |
+
number = st.slider('Выберите число:', 0, 9, step=1)
|
| 92 |
+
|
| 93 |
+
# Вставка кода с кнопками
|
| 94 |
+
container = st.container()
|
| 95 |
+
|
| 96 |
+
# Настройка стиля контейнера с помощью CSS
|
| 97 |
+
container.markdown(
|
| 98 |
+
"""
|
| 99 |
+
<style>
|
| 100 |
+
.container-style {
|
| 101 |
+
display: flex;
|
| 102 |
+
justify-content: center;
|
| 103 |
+
align-items: center;
|
| 104 |
+
margin-top: 20px;
|
| 105 |
+
margin-bottom: 20px;
|
| 106 |
+
}
|
| 107 |
+
</style>
|
| 108 |
+
""",
|
| 109 |
+
unsafe_allow_html=True
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# Расположение кнопок внутри контейнера
|
| 113 |
+
with container:
|
| 114 |
+
col1, col2, col3 = st.columns(3)
|
| 115 |
+
|
| 116 |
+
# Кнопки для перехода на другие страницы
|
| 117 |
+
if col1.button('Страница 1'):
|
| 118 |
+
# Действия при нажатии кнопки для перехода на Страницу 1
|
| 119 |
+
st.experimental_set_query_params(page='?page=1')
|
| 120 |
+
|
| 121 |
+
if col2.button('Страница 2'):
|
| 122 |
+
# Действия при нажатии кнопки для перехода на Страницу 2
|
| 123 |
+
st.experimental_set_query_params(page='2')
|
| 124 |
+
|
| 125 |
+
if col3.button('Страница 3'):
|
| 126 |
+
# Действия при нажатии кнопки для перехода на Страницу 3
|
| 127 |
+
st.experimental_set_query_params(page='third.py')
|
pages/.ipynb_checkpoints/✨third-checkpoint.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
|
| 6 |
+
df = px.data.iris()
|
| 7 |
+
|
| 8 |
+
@st.cache_data
|
| 9 |
+
def get_img_as_base64(file):
|
| 10 |
+
with open(file, "rb") as f:
|
| 11 |
+
data = f.read()
|
| 12 |
+
return base64.b64encode(data).decode()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
#img = get_img_as_base64("https://catherineasquithgallery.com/uploads/posts/2021-02/1612739741_65-p-goluboi-fon-tsifri-110.jpg")
|
| 16 |
+
|
| 17 |
+
page_bg_img = f"""
|
| 18 |
+
<style>
|
| 19 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 20 |
+
background-image: url("https://wallpapercave.com/wp/wp11966930.jpg");
|
| 21 |
+
background-size: 115%;
|
| 22 |
+
background-position: top left;
|
| 23 |
+
background-repeat: no-repeat;
|
| 24 |
+
background-attachment: local;
|
| 25 |
+
}}
|
| 26 |
+
|
| 27 |
+
[data-testid="stSidebar"] > div:first-child {{
|
| 28 |
+
background-image: url("https://ibb.co/ZBkdJRg");
|
| 29 |
+
background-size: 115%;
|
| 30 |
+
background-position: center;
|
| 31 |
+
background-repeat: no-repeat;
|
| 32 |
+
background-attachment: fixed;
|
| 33 |
+
}}
|
| 34 |
+
|
| 35 |
+
[data-testid="stHeader"] {{
|
| 36 |
+
background: rgba(0,0,0,0);
|
| 37 |
+
}}
|
| 38 |
+
|
| 39 |
+
[data-testid="stToolbar"] {{
|
| 40 |
+
right: 2rem;
|
| 41 |
+
}}
|
| 42 |
+
|
| 43 |
+
div.css-1n76uvr.e1tzin5v0 {{
|
| 44 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 45 |
+
border: 10px solid #EEEEEE;
|
| 46 |
+
padding: 5% 5% 5% 10%;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
}}
|
| 49 |
+
|
| 50 |
+
</style>
|
| 51 |
+
"""
|
| 52 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 53 |
+
|
| 54 |
+
import tensorflow as tf
|
| 55 |
+
from tensorflow import keras
|
| 56 |
+
import numpy as np
|
| 57 |
+
import matplotlib.pyplot as plt
|
| 58 |
+
|
| 59 |
+
################################################################################################
|
| 60 |
+
#Тут нужно будет добаить модель. Ниже пример:
|
| 61 |
+
|
| 62 |
+
# # Загрузка модели
|
| 63 |
+
# model = keras.models.load_model('cgan_model.h5')
|
| 64 |
+
|
| 65 |
+
# # Задание размерностей входных данных модели
|
| 66 |
+
# latent_dim = 128
|
| 67 |
+
# num_classes = 10
|
| 68 |
+
|
| 69 |
+
# # Функция для генерации изображения
|
| 70 |
+
# def generate_image(number):
|
| 71 |
+
# random_latent_vector = tf.random.normal(shape=(1, latent_dim))
|
| 72 |
+
# one_hot_label = tf.one_hot([number], num_classes)
|
| 73 |
+
# input_data = tf.concat([random_latent_vector, one_hot_label], axis=1)
|
| 74 |
+
|
| 75 |
+
# generated_image = model.predict(input_data)
|
| 76 |
+
# generated_image = generated_image.reshape(28, 28)
|
| 77 |
+
# generated_image = tf.image.resize(generated_image[None, ...], (28, 28))[0] # Добавлено [None, ...] для добавления измерения
|
| 78 |
+
# return generated_image
|
| 79 |
+
|
| 80 |
+
################################################################################################
|
| 81 |
+
|
| 82 |
+
#Оформление
|
| 83 |
+
|
| 84 |
+
col1, col2, col3 = st.columns([1,5,1])
|
| 85 |
+
with col2:
|
| 86 |
+
|
| 87 |
+
st.title('Название модели')
|
| 88 |
+
|
| 89 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 90 |
+
with col2:
|
| 91 |
+
|
| 92 |
+
number = st.slider('Выберите число:', 0, 9, step=1)
|
| 93 |
+
|
| 94 |
+
################################################################################################
|
| 95 |
+
# Часть, отображаемая на странице
|
| 96 |
+
|
| 97 |
+
# number = st.slider('Выберите число:', 0, 9, step=1)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# #col1.subheader("Гистограмма total_bill:")
|
| 101 |
+
|
| 102 |
+
# # Генерация и отображение изображения
|
| 103 |
+
# generated_image = generate_image(number)
|
| 104 |
+
# generated_image_np = generated_image.numpy() # Преобразование в массив NumPy
|
| 105 |
+
# fig, ax = plt.subplots()
|
| 106 |
+
# ax.scatter([1, 2], [1, 2], color='black')
|
| 107 |
+
# plt.imshow(generated_image_np, cmap='gray')
|
| 108 |
+
# plt.axis('off')
|
| 109 |
+
# fig.set_size_inches(3, 3)
|
| 110 |
+
# st.pyplot(fig)
|
| 111 |
+
|
| 112 |
+
################################################################################################
|
| 113 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
| 114 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
pages/Без названия.ipynb
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "99cbbaf3-6005-4e37-8855-f1d675211128",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [
|
| 9 |
+
{
|
| 10 |
+
"name": "stdout",
|
| 11 |
+
"output_type": "stream",
|
| 12 |
+
"text": [
|
| 13 |
+
"absl-py==1.4.0\n",
|
| 14 |
+
"aiofiles==23.1.0\n",
|
| 15 |
+
"aiogram==2.25.1\n",
|
| 16 |
+
"aiohttp==3.8.4\n",
|
| 17 |
+
"aiosignal==1.3.1\n",
|
| 18 |
+
"altair==4.2.2\n",
|
| 19 |
+
"anyio @ file:///home/conda/feedstock_root/build_artifacts/anyio_1666191106763/work/dist\n",
|
| 20 |
+
"appdirs==1.4.4\n",
|
| 21 |
+
"argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1640817743617/work\n",
|
| 22 |
+
"argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1666850768662/work\n",
|
| 23 |
+
"asttokens==2.2.1\n",
|
| 24 |
+
"astunparse==1.6.3\n",
|
| 25 |
+
"async-timeout==4.0.2\n",
|
| 26 |
+
"attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1671632566681/work\n",
|
| 27 |
+
"Babel==2.9.1\n",
|
| 28 |
+
"backcall==0.2.0\n",
|
| 29 |
+
"backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work\n",
|
| 30 |
+
"beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1679322162244/work\n",
|
| 31 |
+
"bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1674535352125/work\n",
|
| 32 |
+
"blinker==1.6.1\n",
|
| 33 |
+
"brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1666764671472/work\n",
|
| 34 |
+
"cachetools==5.3.0\n",
|
| 35 |
+
"catboost==1.2\n",
|
| 36 |
+
"certifi==2022.12.7\n",
|
| 37 |
+
"cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1671179353105/work\n",
|
| 38 |
+
"charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1661170624537/work\n",
|
| 39 |
+
"click==8.1.3\n",
|
| 40 |
+
"cloudpickle==2.2.1\n",
|
| 41 |
+
"cmake==3.25.0\n",
|
| 42 |
+
"colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work\n",
|
| 43 |
+
"comm==0.1.3\n",
|
| 44 |
+
"conda==23.1.0\n",
|
| 45 |
+
"conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1669907009957/work\n",
|
| 46 |
+
"conda_package_streaming @ file:///home/conda/feedstock_root/build_artifacts/conda-package-streaming_1669733752472/work\n",
|
| 47 |
+
"contourpy==1.0.7\n",
|
| 48 |
+
"cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1675828607645/work\n",
|
| 49 |
+
"cycler==0.11.0\n",
|
| 50 |
+
"Cython==0.29.34\n",
|
| 51 |
+
"debugpy==1.6.6\n",
|
| 52 |
+
"decorator==5.1.1\n",
|
| 53 |
+
"defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work\n",
|
| 54 |
+
"Deprecated==1.2.13\n",
|
| 55 |
+
"entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work\n",
|
| 56 |
+
"executing==1.2.0\n",
|
| 57 |
+
"fastapi==0.95.2\n",
|
| 58 |
+
"fastjsonschema @ file:///home/conda/feedstock_root/build_artifacts/python-fastjsonschema_1677336799617/work/dist\n",
|
| 59 |
+
"ffmpy==0.3.0\n",
|
| 60 |
+
"filelock==3.9.0\n",
|
| 61 |
+
"flatbuffers==23.5.26\n",
|
| 62 |
+
"flit_core @ file:///home/conda/feedstock_root/build_artifacts/flit-core_1667734568827/work/source/flit_core\n",
|
| 63 |
+
"fonttools==4.39.3\n",
|
| 64 |
+
"frozendict==2.3.7\n",
|
| 65 |
+
"frozenlist==1.3.3\n",
|
| 66 |
+
"fsspec==2023.5.0\n",
|
| 67 |
+
"gast==0.4.0\n",
|
| 68 |
+
"gitdb==4.0.10\n",
|
| 69 |
+
"GitPython==3.1.31\n",
|
| 70 |
+
"google-auth==2.19.1\n",
|
| 71 |
+
"google-auth-oauthlib==1.0.0\n",
|
| 72 |
+
"google-pasta==0.2.0\n",
|
| 73 |
+
"gradio==3.32.0\n",
|
| 74 |
+
"gradio_client==0.2.5\n",
|
| 75 |
+
"graphviz==0.20.1\n",
|
| 76 |
+
"grpcio==1.54.2\n",
|
| 77 |
+
"h11==0.14.0\n",
|
| 78 |
+
"h5py==3.8.0\n",
|
| 79 |
+
"html5lib==1.1\n",
|
| 80 |
+
"httpcore==0.17.2\n",
|
| 81 |
+
"httpx==0.24.1\n",
|
| 82 |
+
"huggingface-hub==0.14.1\n",
|
| 83 |
+
"humanize==4.6.0\n",
|
| 84 |
+
"idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1663625384323/work\n",
|
| 85 |
+
"importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1679167925176/work\n",
|
| 86 |
+
"importlib-resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1676919000169/work\n",
|
| 87 |
+
"ipykernel==6.22.0\n",
|
| 88 |
+
"ipython==8.12.0\n",
|
| 89 |
+
"ipython-genutils==0.2.0\n",
|
| 90 |
+
"jax==0.4.11\n",
|
| 91 |
+
"jedi==0.18.2\n",
|
| 92 |
+
"Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1654302431367/work\n",
|
| 93 |
+
"joblib==1.2.0\n",
|
| 94 |
+
"json5 @ file:///home/conda/feedstock_root/build_artifacts/json5_1600692310011/work\n",
|
| 95 |
+
"jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema-meta_1669810440410/work\n",
|
| 96 |
+
"jupyter-events @ file:///home/conda/feedstock_root/build_artifacts/jupyter_events_1673559782596/work\n",
|
| 97 |
+
"jupyter_client==8.1.0\n",
|
| 98 |
+
"jupyter_core==5.3.0\n",
|
| 99 |
+
"jupyter_server @ file:///home/conda/feedstock_root/build_artifacts/jupyter_server_1679073341944/work\n",
|
| 100 |
+
"jupyter_server_terminals @ file:///home/conda/feedstock_root/build_artifacts/jupyter_server_terminals_1673491454549/work\n",
|
| 101 |
+
"jupyterlab @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_1666613090338/work\n",
|
| 102 |
+
"jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1649936611996/work\n",
|
| 103 |
+
"jupyterlab_server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1679528718717/work\n",
|
| 104 |
+
"keras==2.12.0\n",
|
| 105 |
+
"kiwisolver==1.4.4\n",
|
| 106 |
+
"libclang==16.0.0\n",
|
| 107 |
+
"linkify-it-py==2.0.2\n",
|
| 108 |
+
"lit==15.0.7\n",
|
| 109 |
+
"llvmlite==0.40.0\n",
|
| 110 |
+
"lxml==4.9.2\n",
|
| 111 |
+
"magic-filter==1.0.9\n",
|
| 112 |
+
"Markdown==3.4.3\n",
|
| 113 |
+
"markdown-it-py==2.2.0\n",
|
| 114 |
+
"MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1674135787083/work\n",
|
| 115 |
+
"matplotlib==3.7.1\n",
|
| 116 |
+
"matplotlib-inline==0.1.6\n",
|
| 117 |
+
"mdit-py-plugins==0.3.3\n",
|
| 118 |
+
"mdurl==0.1.2\n",
|
| 119 |
+
"mistune @ file:///home/conda/feedstock_root/build_artifacts/mistune_1675771498296/work\n",
|
| 120 |
+
"ml-dtypes==0.1.0\n",
|
| 121 |
+
"mlxtend==0.22.0\n",
|
| 122 |
+
"mpmath==1.2.1\n",
|
| 123 |
+
"multidict==6.0.4\n",
|
| 124 |
+
"multitasking==0.0.11\n",
|
| 125 |
+
"nbclassic @ file:///home/conda/feedstock_root/build_artifacts/nbclassic_1678277563913/work\n",
|
| 126 |
+
"nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1669795076334/work\n",
|
| 127 |
+
"nbconvert @ file:///home/conda/feedstock_root/build_artifacts/nbconvert-meta_1674590374792/work\n",
|
| 128 |
+
"nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1679336765223/work\n",
|
| 129 |
+
"nest-asyncio==1.5.6\n",
|
| 130 |
+
"networkx==3.0\n",
|
| 131 |
+
"nibabel==5.1.0\n",
|
| 132 |
+
"nltk==3.8.1\n",
|
| 133 |
+
"notebook @ file:///home/conda/feedstock_root/build_artifacts/notebook_1678109761260/work\n",
|
| 134 |
+
"notebook_shim @ file:///home/conda/feedstock_root/build_artifacts/notebook-shim_1667478401171/work\n",
|
| 135 |
+
"numba==0.57.0\n",
|
| 136 |
+
"numpy==1.23.5\n",
|
| 137 |
+
"oauthlib==3.2.2\n",
|
| 138 |
+
"opt-einsum==3.3.0\n",
|
| 139 |
+
"orjson==3.8.14\n",
|
| 140 |
+
"packaging==23.0\n",
|
| 141 |
+
"pandas==1.5.3\n",
|
| 142 |
+
"pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work\n",
|
| 143 |
+
"parso==0.8.3\n",
|
| 144 |
+
"patsy==0.5.3\n",
|
| 145 |
+
"pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1667297516076/work\n",
|
| 146 |
+
"pickleshare==0.7.5\n",
|
| 147 |
+
"Pillow==9.5.0\n",
|
| 148 |
+
"pkgutil_resolve_name @ file:///home/conda/feedstock_root/build_artifacts/pkgutil-resolve-name_1633981968097/work\n",
|
| 149 |
+
"platformdirs==3.2.0\n",
|
| 150 |
+
"plotly==5.14.1\n",
|
| 151 |
+
"pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1667232663820/work\n",
|
| 152 |
+
"pmdarima==2.0.3\n",
|
| 153 |
+
"prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1674535637125/work\n",
|
| 154 |
+
"prompt-toolkit==3.0.38\n",
|
| 155 |
+
"protobuf==3.20.3\n",
|
| 156 |
+
"psutil==5.9.4\n",
|
| 157 |
+
"ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl\n",
|
| 158 |
+
"pure-eval==0.2.2\n",
|
| 159 |
+
"pyarrow==11.0.0\n",
|
| 160 |
+
"pyasn1==0.5.0\n",
|
| 161 |
+
"pyasn1-modules==0.3.0\n",
|
| 162 |
+
"pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1666836542287/work\n",
|
| 163 |
+
"pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work\n",
|
| 164 |
+
"pydantic==1.10.8\n",
|
| 165 |
+
"pydeck==0.8.0\n",
|
| 166 |
+
"pydub==0.25.1\n",
|
| 167 |
+
"pyenchant==3.2.2\n",
|
| 168 |
+
"Pygments==2.14.0\n",
|
| 169 |
+
"Pympler==1.0.1\n",
|
| 170 |
+
"pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1672659226110/work\n",
|
| 171 |
+
"pyparsing==3.0.9\n",
|
| 172 |
+
"pyrsistent @ file:///home/conda/feedstock_root/build_artifacts/pyrsistent_1672681463845/work\n",
|
| 173 |
+
"PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work\n",
|
| 174 |
+
"python-dateutil==2.8.2\n",
|
| 175 |
+
"python-json-logger @ file:///home/conda/feedstock_root/build_artifacts/python-json-logger_1677079630776/work\n",
|
| 176 |
+
"python-multipart==0.0.6\n",
|
| 177 |
+
"python-telegram-bot==20.3\n",
|
| 178 |
+
"pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1679742222779/work\n",
|
| 179 |
+
"pytz-deprecation-shim==0.1.0.post0\n",
|
| 180 |
+
"PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1666772395347/work\n",
|
| 181 |
+
"pyzmq==25.0.2\n",
|
| 182 |
+
"regex==2023.5.5\n",
|
| 183 |
+
"requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1673863902341/work\n",
|
| 184 |
+
"requests-oauthlib==1.3.1\n",
|
| 185 |
+
"rfc3339-validator @ file:///home/conda/feedstock_root/build_artifacts/rfc3339-validator_1638811747357/work\n",
|
| 186 |
+
"rfc3986-validator @ file:///home/conda/feedstock_root/build_artifacts/rfc3986-validator_1598024191506/work\n",
|
| 187 |
+
"rich==13.3.3\n",
|
| 188 |
+
"rsa==4.9\n",
|
| 189 |
+
"ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1666827327415/work\n",
|
| 190 |
+
"ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1670412719074/work\n",
|
| 191 |
+
"safetensors==0.3.1\n",
|
| 192 |
+
"scikit-learn==1.2.2\n",
|
| 193 |
+
"scipy==1.10.1\n",
|
| 194 |
+
"seaborn==0.12.2\n",
|
| 195 |
+
"semantic-version==2.10.0\n",
|
| 196 |
+
"Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1628511208346/work\n",
|
| 197 |
+
"shap==0.41.0\n",
|
| 198 |
+
"shellingham==1.5.0.post1\n",
|
| 199 |
+
"SimpleITK==2.2.1\n",
|
| 200 |
+
"six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work\n",
|
| 201 |
+
"sklearn==0.0.post1\n",
|
| 202 |
+
"slicer==0.0.7\n",
|
| 203 |
+
"smmap==5.0.0\n",
|
| 204 |
+
"sniffio @ file:///home/conda/feedstock_root/build_artifacts/sniffio_1662051266223/work\n",
|
| 205 |
+
"soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1658207591808/work\n",
|
| 206 |
+
"stack-data==0.6.2\n",
|
| 207 |
+
"starlette==0.27.0\n",
|
| 208 |
+
"statsmodels==0.14.0\n",
|
| 209 |
+
"streamlit==1.23.1\n",
|
| 210 |
+
"streamlit-nightly==1.23.2.dev20230607\n",
|
| 211 |
+
"sympy==1.11.1\n",
|
| 212 |
+
"tabulate==0.9.0\n",
|
| 213 |
+
"tenacity==8.2.2\n",
|
| 214 |
+
"tensorboard==2.12.3\n",
|
| 215 |
+
"tensorboard-data-server==0.7.0\n",
|
| 216 |
+
"tensorflow==2.12.0\n",
|
| 217 |
+
"tensorflow-estimator==2.12.0\n",
|
| 218 |
+
"tensorflow-io-gcs-filesystem==0.32.0\n",
|
| 219 |
+
"termcolor==2.3.0\n",
|
| 220 |
+
"terminado @ file:///home/conda/feedstock_root/build_artifacts/terminado_1670253674810/work\n",
|
| 221 |
+
"threadpoolctl==3.1.0\n",
|
| 222 |
+
"tinycss2 @ file:///home/conda/feedstock_root/build_artifacts/tinycss2_1666100256010/work\n",
|
| 223 |
+
"tokenizers==0.13.3\n",
|
| 224 |
+
"toml==0.10.2\n",
|
| 225 |
+
"tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1644342247877/work\n",
|
| 226 |
+
"toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1657485559105/work\n",
|
| 227 |
+
"torch==2.0.1+cu118\n",
|
| 228 |
+
"torchaudio==2.0.2+cu118\n",
|
| 229 |
+
"torchio==0.18.91\n",
|
| 230 |
+
"torchmetrics==0.11.4\n",
|
| 231 |
+
"torchutils==0.0.4\n",
|
| 232 |
+
"torchvision==0.15.2+cu118\n",
|
| 233 |
+
"tornado==6.2\n",
|
| 234 |
+
"tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1662214488106/work\n",
|
| 235 |
+
"traitlets==5.9.0\n",
|
| 236 |
+
"transformers==4.30.0\n",
|
| 237 |
+
"translit==0.2a1\n",
|
| 238 |
+
"triton==2.0.0\n",
|
| 239 |
+
"typer==0.9.0\n",
|
| 240 |
+
"typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1678559861143/work\n",
|
| 241 |
+
"tzdata==2023.3\n",
|
| 242 |
+
"tzlocal==4.3\n",
|
| 243 |
+
"uc-micro-py==1.0.2\n",
|
| 244 |
+
"urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1673452138552/work\n",
|
| 245 |
+
"uvicorn==0.22.0\n",
|
| 246 |
+
"validators==0.20.0\n",
|
| 247 |
+
"watchdog==3.0.0\n",
|
| 248 |
+
"wcwidth==0.2.6\n",
|
| 249 |
+
"webencodings==0.5.1\n",
|
| 250 |
+
"websocket-client @ file:///home/conda/feedstock_root/build_artifacts/websocket-client_1675567828044/work\n",
|
| 251 |
+
"websockets==11.0.3\n",
|
| 252 |
+
"Werkzeug==2.3.4\n",
|
| 253 |
+
"wrapt==1.14.1\n",
|
| 254 |
+
"xlrd==2.0.1\n",
|
| 255 |
+
"yarl==1.8.2\n",
|
| 256 |
+
"yellowbrick==1.5\n",
|
| 257 |
+
"yfinance==0.2.17\n",
|
| 258 |
+
"zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1677313463193/work\n",
|
| 259 |
+
"zstandard==0.19.0\n",
|
| 260 |
+
"Note: you may need to restart the kernel to use updated packages.\n"
|
| 261 |
+
]
|
| 262 |
+
}
|
| 263 |
+
],
|
| 264 |
+
"source": [
|
| 265 |
+
"pip freeze"
|
| 266 |
+
]
|
| 267 |
+
},
|
| 268 |
+
{
|
| 269 |
+
"cell_type": "code",
|
| 270 |
+
"execution_count": 3,
|
| 271 |
+
"id": "fba03be3-8dd0-48d4-898c-a7eb2fd5c292",
|
| 272 |
+
"metadata": {},
|
| 273 |
+
"outputs": [],
|
| 274 |
+
"source": [
|
| 275 |
+
"import torch"
|
| 276 |
+
]
|
| 277 |
+
},
|
| 278 |
+
{
|
| 279 |
+
"cell_type": "code",
|
| 280 |
+
"execution_count": 4,
|
| 281 |
+
"id": "fe9c5e5e-2bc8-4585-93e1-4b777ddeb7c4",
|
| 282 |
+
"metadata": {},
|
| 283 |
+
"outputs": [
|
| 284 |
+
{
|
| 285 |
+
"data": {
|
| 286 |
+
"text/plain": [
|
| 287 |
+
"'2.0.1+cu118'"
|
| 288 |
+
]
|
| 289 |
+
},
|
| 290 |
+
"execution_count": 4,
|
| 291 |
+
"metadata": {},
|
| 292 |
+
"output_type": "execute_result"
|
| 293 |
+
}
|
| 294 |
+
],
|
| 295 |
+
"source": [
|
| 296 |
+
"torch.__version__"
|
| 297 |
+
]
|
| 298 |
+
},
|
| 299 |
+
{
|
| 300 |
+
"cell_type": "code",
|
| 301 |
+
"execution_count": 1,
|
| 302 |
+
"id": "ce5f014d-d484-43a6-ad7f-9e0ba8ba46af",
|
| 303 |
+
"metadata": {},
|
| 304 |
+
"outputs": [
|
| 305 |
+
{
|
| 306 |
+
"name": "stdout",
|
| 307 |
+
"output_type": "stream",
|
| 308 |
+
"text": [
|
| 309 |
+
"Collecting transformers\n",
|
| 310 |
+
" Downloading transformers-4.30.0-py3-none-any.whl (7.2 MB)\n",
|
| 311 |
+
"\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.2/7.2 MB\u001b[0m \u001b[31m1.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m0:00:01\u001b[0m[36m0:00:01\u001b[0m0m\n",
|
| 312 |
+
"\u001b[?25hRequirement already satisfied: filelock in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (3.9.0)\n",
|
| 313 |
+
"Requirement already satisfied: huggingface-hub<1.0,>=0.14.1 in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (0.14.1)\n",
|
| 314 |
+
"Requirement already satisfied: numpy>=1.17 in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (1.23.5)\n",
|
| 315 |
+
"Requirement already satisfied: packaging>=20.0 in /home/maria/.local/lib/python3.10/site-packages (from transformers) (23.0)\n",
|
| 316 |
+
"Requirement already satisfied: pyyaml>=5.1 in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (6.0)\n",
|
| 317 |
+
"Requirement already satisfied: regex!=2019.12.17 in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (2023.5.5)\n",
|
| 318 |
+
"Requirement already satisfied: requests in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (2.28.2)\n",
|
| 319 |
+
"Collecting tokenizers!=0.11.3,<0.14,>=0.11.1 (from transformers)\n",
|
| 320 |
+
" Downloading tokenizers-0.13.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.8 MB)\n",
|
| 321 |
+
"\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.8/7.8 MB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m0:00:01\u001b[0m[36m0:00:01\u001b[0m\n",
|
| 322 |
+
"\u001b[?25hCollecting safetensors>=0.3.1 (from transformers)\n",
|
| 323 |
+
" Downloading safetensors-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)\n",
|
| 324 |
+
"\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m0:00:01\u001b[0m0:01\u001b[0m:01\u001b[0mm\n",
|
| 325 |
+
"\u001b[?25hRequirement already satisfied: tqdm>=4.27 in /home/maria/miniforge3/lib/python3.10/site-packages (from transformers) (4.64.1)\n",
|
| 326 |
+
"Requirement already satisfied: fsspec in /home/maria/miniforge3/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.14.1->transformers) (2023.5.0)\n",
|
| 327 |
+
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/maria/miniforge3/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.14.1->transformers) (4.5.0)\n",
|
| 328 |
+
"Requirement already satisfied: charset-normalizer<4,>=2 in /home/maria/miniforge3/lib/python3.10/site-packages (from requests->transformers) (2.1.1)\n",
|
| 329 |
+
"Requirement already satisfied: idna<4,>=2.5 in /home/maria/miniforge3/lib/python3.10/site-packages (from requests->transformers) (3.4)\n",
|
| 330 |
+
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/maria/miniforge3/lib/python3.10/site-packages (from requests->transformers) (1.26.14)\n",
|
| 331 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /home/maria/miniforge3/lib/python3.10/site-packages (from requests->transformers) (2022.12.7)\n",
|
| 332 |
+
"Installing collected packages: tokenizers, safetensors, transformers\n",
|
| 333 |
+
"Successfully installed safetensors-0.3.1 tokenizers-0.13.3 transformers-4.30.0\n"
|
| 334 |
+
]
|
| 335 |
+
}
|
| 336 |
+
],
|
| 337 |
+
"source": [
|
| 338 |
+
"!pip install transformers"
|
| 339 |
+
]
|
| 340 |
+
},
|
| 341 |
+
{
|
| 342 |
+
"cell_type": "code",
|
| 343 |
+
"execution_count": null,
|
| 344 |
+
"id": "fc355448-1c49-4bda-8196-caec91650f40",
|
| 345 |
+
"metadata": {},
|
| 346 |
+
"outputs": [],
|
| 347 |
+
"source": []
|
| 348 |
+
}
|
| 349 |
+
],
|
| 350 |
+
"metadata": {
|
| 351 |
+
"kernelspec": {
|
| 352 |
+
"display_name": "Python 3 (ipykernel)",
|
| 353 |
+
"language": "python",
|
| 354 |
+
"name": "python3"
|
| 355 |
+
},
|
| 356 |
+
"language_info": {
|
| 357 |
+
"codemirror_mode": {
|
| 358 |
+
"name": "ipython",
|
| 359 |
+
"version": 3
|
| 360 |
+
},
|
| 361 |
+
"file_extension": ".py",
|
| 362 |
+
"mimetype": "text/x-python",
|
| 363 |
+
"name": "python",
|
| 364 |
+
"nbconvert_exporter": "python",
|
| 365 |
+
"pygments_lexer": "ipython3",
|
| 366 |
+
"version": "3.10.9"
|
| 367 |
+
}
|
| 368 |
+
},
|
| 369 |
+
"nbformat": 4,
|
| 370 |
+
"nbformat_minor": 5
|
| 371 |
+
}
|
pages/✨BERT.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
|
| 6 |
+
df = px.data.iris()
|
| 7 |
+
|
| 8 |
+
@st.cache_data
|
| 9 |
+
def get_img_as_base64(file):
|
| 10 |
+
with open(file, "rb") as f:
|
| 11 |
+
data = f.read()
|
| 12 |
+
return base64.b64encode(data).decode()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
page_bg_img = f"""
|
| 16 |
+
<style>
|
| 17 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 18 |
+
background-image: url("https://i.ibb.co/kH8bcr4/1368432.jpg");
|
| 19 |
+
background-size: 115%;
|
| 20 |
+
background-position: top left;
|
| 21 |
+
background-repeat: no-repeat;
|
| 22 |
+
background-attachment: local;
|
| 23 |
+
}}
|
| 24 |
+
|
| 25 |
+
[data-testid="stSidebar"] > div:first-child {{
|
| 26 |
+
background-image: url("https://ibb.co/ZBkdJRg");
|
| 27 |
+
background-size: 115%;
|
| 28 |
+
background-position: center;
|
| 29 |
+
background-repeat: no-repeat;
|
| 30 |
+
background-attachment: fixed;
|
| 31 |
+
}}
|
| 32 |
+
|
| 33 |
+
[data-testid="stHeader"] {{
|
| 34 |
+
background: rgba(0,0,0,0);
|
| 35 |
+
}}
|
| 36 |
+
|
| 37 |
+
[data-testid="stToolbar"] {{
|
| 38 |
+
right: 2rem;
|
| 39 |
+
}}
|
| 40 |
+
|
| 41 |
+
div.css-1n76uvr.e1tzin5v0 {{
|
| 42 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 43 |
+
border: 10px solid #EEEEEE;
|
| 44 |
+
padding: 5% 5% 5% 10%;
|
| 45 |
+
border-radius: 5px;
|
| 46 |
+
}}
|
| 47 |
+
|
| 48 |
+
</style>
|
| 49 |
+
"""
|
| 50 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 51 |
+
|
| 52 |
+
import tensorflow as tf
|
| 53 |
+
from tensorflow import keras
|
| 54 |
+
import numpy as np
|
| 55 |
+
import matplotlib.pyplot as plt
|
| 56 |
+
|
| 57 |
+
################################################################################################
|
| 58 |
+
import torch
|
| 59 |
+
import numpy as np
|
| 60 |
+
import transformers
|
| 61 |
+
import pickle
|
| 62 |
+
from sklearn.linear_model import LogisticRegression
|
| 63 |
+
|
| 64 |
+
#def load_model():
|
| 65 |
+
model = transformers.DistilBertModel.from_pretrained(
|
| 66 |
+
"distilbert-base-uncased",
|
| 67 |
+
output_attentions = False,
|
| 68 |
+
output_hidden_states = False
|
| 69 |
+
)
|
| 70 |
+
#model.load_state_dict(torch.load('model/modelbert.pt', map_location=torch.device('cpu')))
|
| 71 |
+
tokenizer = transformers.DistilBertTokenizer.from_pretrained("distilbert-base-uncased")
|
| 72 |
+
#return model_finetuned, tokenizer
|
| 73 |
+
|
| 74 |
+
def preprocess_text(text_input, max_len, tokenizer):
|
| 75 |
+
input_tokens = tokenizer(
|
| 76 |
+
text_input,
|
| 77 |
+
return_tensors='pt',
|
| 78 |
+
padding=True,
|
| 79 |
+
max_length=max_len,
|
| 80 |
+
truncation = True
|
| 81 |
+
)
|
| 82 |
+
return input_tokens
|
| 83 |
+
|
| 84 |
+
def predict_sentiment(model, input_tokens):
|
| 85 |
+
#st.write(input_tokens)
|
| 86 |
+
ans = {0: "NEGATIVE", 1: "POSITIVE"}
|
| 87 |
+
last_hidden_states = model(**input_tokens)
|
| 88 |
+
#st.write('last_hidden_states ok')
|
| 89 |
+
vectors = last_hidden_states[0][:,0,:].detach().cpu().numpy()
|
| 90 |
+
#st.write('vectors ok')
|
| 91 |
+
#output = model(**input_tokens).last_hidden_states.detach().numpy()
|
| 92 |
+
with open('model/modelbert1.pkl', 'rb') as file:
|
| 93 |
+
cls = pickle.load(file)
|
| 94 |
+
result = ans[cls.predict(vectors)[0]]
|
| 95 |
+
return result
|
| 96 |
+
|
| 97 |
+
col1, col2, col3 = st.columns([1,5,1])
|
| 98 |
+
with col2:
|
| 99 |
+
|
| 100 |
+
st.title('Text sentiment analysis')
|
| 101 |
+
|
| 102 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 103 |
+
with col2:
|
| 104 |
+
|
| 105 |
+
max_len = st.slider('Maximum word length', 0, 500, 250)
|
| 106 |
+
|
| 107 |
+
text_input = st.text_input("Enter some text")
|
| 108 |
+
#model, tokenizer = load_model()
|
| 109 |
+
|
| 110 |
+
if text_input:
|
| 111 |
+
input_tokens = preprocess_text(text_input, max_len, tokenizer)
|
| 112 |
+
output = predict_sentiment(model, input_tokens)
|
| 113 |
+
st.write(output)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
################################################################################################
|
| 118 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
| 119 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
pages/✨first.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
|
| 6 |
+
df = px.data.iris()
|
| 7 |
+
|
| 8 |
+
@st.cache_data
|
| 9 |
+
def get_img_as_base64(file):
|
| 10 |
+
with open(file, "rb") as f:
|
| 11 |
+
data = f.read()
|
| 12 |
+
return base64.b64encode(data).decode()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
page_bg_img = f"""
|
| 16 |
+
<style>
|
| 17 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 18 |
+
background-image: url("https://wallpapercave.com/wp/wp6480460.jpg");
|
| 19 |
+
background-size: 115%;
|
| 20 |
+
background-position: top left;
|
| 21 |
+
background-repeat: no-repeat;
|
| 22 |
+
background-attachment: local;
|
| 23 |
+
}}
|
| 24 |
+
|
| 25 |
+
[data-testid="stSidebar"] > div:first-child {{
|
| 26 |
+
background-image: url("https://ibb.co/ZBkdJRg");
|
| 27 |
+
background-size: 115%;
|
| 28 |
+
background-position: center;
|
| 29 |
+
background-repeat: no-repeat;
|
| 30 |
+
background-attachment: fixed;
|
| 31 |
+
}}
|
| 32 |
+
|
| 33 |
+
[data-testid="stHeader"] {{
|
| 34 |
+
background: rgba(0,0,0,0);
|
| 35 |
+
}}
|
| 36 |
+
|
| 37 |
+
[data-testid="stToolbar"] {{
|
| 38 |
+
right: 2rem;
|
| 39 |
+
}}
|
| 40 |
+
|
| 41 |
+
div.css-1n76uvr.e1tzin5v0 {{
|
| 42 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 43 |
+
border: 10px solid #EEEEEE;
|
| 44 |
+
padding: 5% 5% 5% 10%;
|
| 45 |
+
border-radius: 5px;
|
| 46 |
+
}}
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
</style>
|
| 50 |
+
"""
|
| 51 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 52 |
+
|
| 53 |
+
import tensorflow as tf
|
| 54 |
+
from tensorflow import keras
|
| 55 |
+
import numpy as np
|
| 56 |
+
import matplotlib.pyplot as plt
|
| 57 |
+
|
| 58 |
+
################################################################################################
|
| 59 |
+
#Тут нужно будет добаить модель. Ниже пример:
|
| 60 |
+
|
| 61 |
+
# # Загрузка модели
|
| 62 |
+
# model = keras.models.load_model('cgan_model.h5')
|
| 63 |
+
|
| 64 |
+
# # Задание размерностей входных данных модели
|
| 65 |
+
# latent_dim = 128
|
| 66 |
+
# num_classes = 10
|
| 67 |
+
|
| 68 |
+
# # Функция для генерации изображения
|
| 69 |
+
# def generate_image(number):
|
| 70 |
+
# random_latent_vector = tf.random.normal(shape=(1, latent_dim))
|
| 71 |
+
# one_hot_label = tf.one_hot([number], num_classes)
|
| 72 |
+
# input_data = tf.concat([random_latent_vector, one_hot_label], axis=1)
|
| 73 |
+
|
| 74 |
+
# generated_image = model.predict(input_data)
|
| 75 |
+
# generated_image = generated_image.reshape(28, 28)
|
| 76 |
+
# generated_image = tf.image.resize(generated_image[None, ...], (28, 28))[0] # Добавлено [None, ...] для добавления измерения
|
| 77 |
+
# return generated_image
|
| 78 |
+
|
| 79 |
+
################################################################################################
|
| 80 |
+
|
| 81 |
+
#Оформление
|
| 82 |
+
|
| 83 |
+
col1, col2, col3 = st.columns([1,5,1])
|
| 84 |
+
with col2:
|
| 85 |
+
|
| 86 |
+
st.title('Название модели')
|
| 87 |
+
|
| 88 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 89 |
+
with col2:
|
| 90 |
+
|
| 91 |
+
number = st.slider('Выберите число:', 0, 9, step=1)
|
| 92 |
+
|
| 93 |
+
# Вставка кода с кнопками
|
| 94 |
+
container = st.container()
|
| 95 |
+
|
| 96 |
+
# Настройка стиля контейнера с помощью CSS
|
| 97 |
+
container.markdown(
|
| 98 |
+
"""
|
| 99 |
+
<style>
|
| 100 |
+
.container-style {
|
| 101 |
+
display: flex;
|
| 102 |
+
justify-content: center;
|
| 103 |
+
align-items: center;
|
| 104 |
+
margin-top: 20px;
|
| 105 |
+
margin-bottom: 20px;
|
| 106 |
+
}
|
| 107 |
+
</style>
|
| 108 |
+
""",
|
| 109 |
+
unsafe_allow_html=True
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# Расположение кнопок внутри контейнера
|
| 113 |
+
with container:
|
| 114 |
+
col1, col2, col3 = st.columns(3)
|
| 115 |
+
|
| 116 |
+
# Кнопки для перехода на другие страницы
|
| 117 |
+
if col1.button('Страница 1'):
|
| 118 |
+
# Действия при нажатии кнопки для перехода на Страницу 1
|
| 119 |
+
st.experimental_set_query_params(page='?page=1')
|
| 120 |
+
|
| 121 |
+
if col2.button('Страница 2'):
|
| 122 |
+
# Действия при нажатии кнопки для перехода на Страницу 2
|
| 123 |
+
st.experimental_set_query_params(page='2')
|
| 124 |
+
|
| 125 |
+
if col3.button('Страница 3'):
|
| 126 |
+
# Действия при нажатии кнопки для перехода на Страницу 3
|
| 127 |
+
st.experimental_set_query_params(page='third.py')
|
pages/✨third.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import base64
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import plotly.express as px
|
| 5 |
+
|
| 6 |
+
df = px.data.iris()
|
| 7 |
+
|
| 8 |
+
@st.cache_data
|
| 9 |
+
def get_img_as_base64(file):
|
| 10 |
+
with open(file, "rb") as f:
|
| 11 |
+
data = f.read()
|
| 12 |
+
return base64.b64encode(data).decode()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
#img = get_img_as_base64("https://catherineasquithgallery.com/uploads/posts/2021-02/1612739741_65-p-goluboi-fon-tsifri-110.jpg")
|
| 16 |
+
|
| 17 |
+
page_bg_img = f"""
|
| 18 |
+
<style>
|
| 19 |
+
[data-testid="stAppViewContainer"] > .main {{
|
| 20 |
+
background-image: url("https://wallpapercave.com/wp/wp11966930.jpg");
|
| 21 |
+
background-size: 115%;
|
| 22 |
+
background-position: top left;
|
| 23 |
+
background-repeat: no-repeat;
|
| 24 |
+
background-attachment: local;
|
| 25 |
+
}}
|
| 26 |
+
|
| 27 |
+
[data-testid="stSidebar"] > div:first-child {{
|
| 28 |
+
background-image: url("https://ibb.co/ZBkdJRg");
|
| 29 |
+
background-size: 115%;
|
| 30 |
+
background-position: center;
|
| 31 |
+
background-repeat: no-repeat;
|
| 32 |
+
background-attachment: fixed;
|
| 33 |
+
}}
|
| 34 |
+
|
| 35 |
+
[data-testid="stHeader"] {{
|
| 36 |
+
background: rgba(0,0,0,0);
|
| 37 |
+
}}
|
| 38 |
+
|
| 39 |
+
[data-testid="stToolbar"] {{
|
| 40 |
+
right: 2rem;
|
| 41 |
+
}}
|
| 42 |
+
|
| 43 |
+
div.css-1n76uvr.e1tzin5v0 {{
|
| 44 |
+
background-color: rgba(238, 238, 238, 0.5);
|
| 45 |
+
border: 10px solid #EEEEEE;
|
| 46 |
+
padding: 5% 5% 5% 10%;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
}}
|
| 49 |
+
|
| 50 |
+
</style>
|
| 51 |
+
"""
|
| 52 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 53 |
+
|
| 54 |
+
import tensorflow as tf
|
| 55 |
+
from tensorflow import keras
|
| 56 |
+
import numpy as np
|
| 57 |
+
import matplotlib.pyplot as plt
|
| 58 |
+
|
| 59 |
+
################################################################################################
|
| 60 |
+
#Тут нужно будет добаить модель. Ниже пример:
|
| 61 |
+
|
| 62 |
+
# # Загрузка модели
|
| 63 |
+
# model = keras.models.load_model('cgan_model.h5')
|
| 64 |
+
|
| 65 |
+
# # Задание размерностей входных данных модели
|
| 66 |
+
# latent_dim = 128
|
| 67 |
+
# num_classes = 10
|
| 68 |
+
|
| 69 |
+
# # Функция для генерации изображения
|
| 70 |
+
# def generate_image(number):
|
| 71 |
+
# random_latent_vector = tf.random.normal(shape=(1, latent_dim))
|
| 72 |
+
# one_hot_label = tf.one_hot([number], num_classes)
|
| 73 |
+
# input_data = tf.concat([random_latent_vector, one_hot_label], axis=1)
|
| 74 |
+
|
| 75 |
+
# generated_image = model.predict(input_data)
|
| 76 |
+
# generated_image = generated_image.reshape(28, 28)
|
| 77 |
+
# generated_image = tf.image.resize(generated_image[None, ...], (28, 28))[0] # Добавлено [None, ...] для добавления измерения
|
| 78 |
+
# return generated_image
|
| 79 |
+
|
| 80 |
+
################################################################################################
|
| 81 |
+
|
| 82 |
+
#Оформление
|
| 83 |
+
|
| 84 |
+
col1, col2, col3 = st.columns([1,5,1])
|
| 85 |
+
with col2:
|
| 86 |
+
|
| 87 |
+
st.title('Название модели')
|
| 88 |
+
|
| 89 |
+
col1, col2, col3 = st.columns([2,5,2])
|
| 90 |
+
with col2:
|
| 91 |
+
|
| 92 |
+
number = st.slider('Выберите число:', 0, 9, step=1)
|
| 93 |
+
|
| 94 |
+
################################################################################################
|
| 95 |
+
# Часть, отображаемая на странице
|
| 96 |
+
|
| 97 |
+
# number = st.slider('Выберите число:', 0, 9, step=1)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# #col1.subheader("Гистограмма total_bill:")
|
| 101 |
+
|
| 102 |
+
# # Генерация и отображение изображения
|
| 103 |
+
# generated_image = generate_image(number)
|
| 104 |
+
# generated_image_np = generated_image.numpy() # Преобразование в массив NumPy
|
| 105 |
+
# fig, ax = plt.subplots()
|
| 106 |
+
# ax.scatter([1, 2], [1, 2], color='black')
|
| 107 |
+
# plt.imshow(generated_image_np, cmap='gray')
|
| 108 |
+
# plt.axis('off')
|
| 109 |
+
# fig.set_size_inches(3, 3)
|
| 110 |
+
# st.pyplot(fig)
|
| 111 |
+
|
| 112 |
+
################################################################################################
|
| 113 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|
| 114 |
+
#st.markdown("<div style='text-align: center; font-size: 25px;'> ", unsafe_allow_html=True)
|