Maslov-Artem
commited on
Commit
·
d632bd4
1
Parent(s):
3a905e4
Add tg page
Browse files- pages/telegram.py +45 -0
pages/telegram.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import base64
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# Function to get base64 string from an image file
|
| 7 |
+
def get_base64(file_path):
|
| 8 |
+
with open(file_path, "rb") as file:
|
| 9 |
+
base64_bytes = base64.b64encode(file.read())
|
| 10 |
+
base64_string = base64_bytes.decode("utf-8")
|
| 11 |
+
return base64_string
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Function to set background image
|
| 15 |
+
def set_background(png_file):
|
| 16 |
+
bin_str = get_base64(png_file)
|
| 17 |
+
page_bg_img = (
|
| 18 |
+
"""
|
| 19 |
+
<style>
|
| 20 |
+
.stApp {
|
| 21 |
+
background-image: url("data:image/png;base64,%s");
|
| 22 |
+
background-size: auto;
|
| 23 |
+
}
|
| 24 |
+
</style>
|
| 25 |
+
"""
|
| 26 |
+
% bin_str
|
| 27 |
+
)
|
| 28 |
+
st.markdown(page_bg_img, unsafe_allow_html=True)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Set background image
|
| 32 |
+
set_background("tg_toxic.png")
|
| 33 |
+
|
| 34 |
+
title_html = """<p style='font-size: 50px; color: black;'>Toxicity Assessment of User Comments</p>"""
|
| 35 |
+
st.markdown(title_html, unsafe_allow_html=True)
|
| 36 |
+
# Title and text with styled hyperlink
|
| 37 |
+
st.write(
|
| 38 |
+
"""<p style='font-size: 18px; color: black;'>Used model: rubert-tiny-toxicity</p>
|
| 39 |
+
<p style='font-size: 18px; color: black;'>Accuracy:</p>
|
| 40 |
+
<p style='font-size: 18px; color: black;'>Pretrained model: 82%</p>
|
| 41 |
+
<p style='font-size: 18px; color: black;'>After training on user's data: 90%</p>
|
| 42 |
+
<a href='https://t.me/toxicity_assessment12345_bot' style='font-size: 18px; color: black; text-decoration: underline;'>Link: Toxicity Assessment Bot</a>
|
| 43 |
+
""",
|
| 44 |
+
unsafe_allow_html=True,
|
| 45 |
+
)
|