Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,7 @@ st.set_page_config(
|
|
21 |
page_icon="π"
|
22 |
)
|
23 |
|
|
|
24 |
# Split large response into smaller chunks (for translation)
|
25 |
# def split_text_into_chunks(text, max_length=450):
|
26 |
# lines = text.split('\n')
|
@@ -36,6 +37,51 @@ st.set_page_config(
|
|
36 |
# chunks.append(current.strip())
|
37 |
# return chunks
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
def save_text_as_image(text, file_path):
|
40 |
font = ImageFont.load_default()
|
41 |
lines = text.split('\n')
|
@@ -53,6 +99,9 @@ def save_text_as_image(text, file_path):
|
|
53 |
img.save(file_path)
|
54 |
return file_path
|
55 |
|
|
|
|
|
|
|
56 |
st.sidebar.title("π MediAssist")
|
57 |
st.sidebar.markdown("Analyze prescriptions with ease using AI")
|
58 |
st.sidebar.markdown("---")
|
|
|
21 |
page_icon="π"
|
22 |
)
|
23 |
|
24 |
+
|
25 |
# Split large response into smaller chunks (for translation)
|
26 |
# def split_text_into_chunks(text, max_length=450):
|
27 |
# lines = text.split('\n')
|
|
|
37 |
# chunks.append(current.strip())
|
38 |
# return chunks
|
39 |
|
40 |
+
|
41 |
+
def set_background(image_file):
|
42 |
+
with open(image_file, "rb") as image:
|
43 |
+
encoded = base64.b64encode(image.read()).decode()
|
44 |
+
st.markdown(
|
45 |
+
f"""
|
46 |
+
<style>
|
47 |
+
.stApp {{
|
48 |
+
background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
|
49 |
+
url("data:image/jpg;base64,{encoded}");
|
50 |
+
background-size: cover;
|
51 |
+
background-repeat: no-repeat;
|
52 |
+
background-attachment: fixed;
|
53 |
+
}}
|
54 |
+
.main-title {{
|
55 |
+
color: #ffffff;
|
56 |
+
text-align: center;
|
57 |
+
font-size: 3em;
|
58 |
+
font-weight: bold;
|
59 |
+
margin-bottom: 0.2em;
|
60 |
+
}}
|
61 |
+
.subtitle {{
|
62 |
+
color: #dddddd;
|
63 |
+
text-align: center;
|
64 |
+
font-size: 1.3em;
|
65 |
+
margin-bottom: 0.5em;
|
66 |
+
}}
|
67 |
+
.quote {{
|
68 |
+
color: #bbbbbb;
|
69 |
+
text-align: center;
|
70 |
+
font-style: italic;
|
71 |
+
font-size: 1.1em;
|
72 |
+
margin-bottom: 2em;
|
73 |
+
}}
|
74 |
+
.stButton>button {{
|
75 |
+
width: 100%;
|
76 |
+
font-size: 1.1em;
|
77 |
+
padding: 0.8em;
|
78 |
+
border-radius: 10px;
|
79 |
+
}}
|
80 |
+
</style>
|
81 |
+
""",
|
82 |
+
unsafe_allow_html=True
|
83 |
+
)
|
84 |
+
|
85 |
def save_text_as_image(text, file_path):
|
86 |
font = ImageFont.load_default()
|
87 |
lines = text.split('\n')
|
|
|
99 |
img.save(file_path)
|
100 |
return file_path
|
101 |
|
102 |
+
|
103 |
+
set_background("background_img.jpg")
|
104 |
+
|
105 |
st.sidebar.title("π MediAssist")
|
106 |
st.sidebar.markdown("Analyze prescriptions with ease using AI")
|
107 |
st.sidebar.markdown("---")
|