Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,313 +1,313 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import joblib
|
| 3 |
-
|
| 4 |
-
# تحميل الموديل
|
| 5 |
-
@st.cache_resource # حتى لا يعيد التحميل كل مرة
|
| 6 |
-
def load_model():
|
| 7 |
-
model = joblib.load("
|
| 8 |
-
return model
|
| 9 |
-
|
| 10 |
-
model = load_model()
|
| 11 |
-
|
| 12 |
-
# اللغات
|
| 13 |
-
languages = {
|
| 14 |
-
"🇲🇦 العربية": {"title": "📊 توقع حالة النبات", "predict": "🔍 تنبؤ", "result": "🔍 النتيجة",
|
| 15 |
-
"temp": "درجة الحرارة (°C)", "hum": "الرطوبة (%)", "tds": "قيمة TDS (ppm)",
|
| 16 |
-
"ph": "مستوى pH", "days": "أيام النمو"},
|
| 17 |
-
"🇺🇸 English": {"title": "📊 Plant Status Prediction", "predict": "🔍 Predict", "result": "🔍 Result",
|
| 18 |
-
"temp": "Temperature (°C)", "hum": "Humidity (%)", "tds": "TDS Value (ppm)",
|
| 19 |
-
"ph": "pH Level", "days": "Growth Days"},
|
| 20 |
-
"🇫🇷 Français": {"title": "📊 Prédiction de l'État de la Plante", "predict": "🔍 Prédire", "result": "🔍 Résultat",
|
| 21 |
-
"temp": "Température (°C)", "hum": "Humidité (%)", "tds": "Valeur TDS (ppm)",
|
| 22 |
-
"ph": "Niveau pH", "days": "Jours de croissance"}
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
# اختيار اللغة
|
| 26 |
-
language = st.sidebar.selectbox(
|
| 27 |
-
"🌍 اختر اللغة / Choose Language / Choisissez la langue",
|
| 28 |
-
list(languages.keys()),
|
| 29 |
-
key="language_selectbox" # إضافة مفتاح فريد
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
texts = languages[language]
|
| 33 |
-
|
| 34 |
-
# اختيار الوضع (Light or Dark Mode)
|
| 35 |
-
theme = st.sidebar.radio(
|
| 36 |
-
"🌙/🌞 اختر الوضع",
|
| 37 |
-
("Light Mode", "Dark Mode"),
|
| 38 |
-
key="theme_radio" # مفتاح فريد للوضع
|
| 39 |
-
)
|
| 40 |
-
|
| 41 |
-
# تخصيص الألوان في الوضع الفاتح
|
| 42 |
-
if theme == "Light Mode":
|
| 43 |
-
st.markdown(
|
| 44 |
-
"""
|
| 45 |
-
<style>
|
| 46 |
-
:root {
|
| 47 |
-
--primary: #1e88e5;
|
| 48 |
-
--primary-hover: #1565c0;
|
| 49 |
-
--background: #f8f9fa;
|
| 50 |
-
--secondary-background: #ffffff;
|
| 51 |
-
--text: #212121;
|
| 52 |
-
--secondary-text: #616161;
|
| 53 |
-
--border: #e0e0e0;
|
| 54 |
-
--hover: #f5f5f5;
|
| 55 |
-
--shadow: rgba(0,0,0,0.1);
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
body {
|
| 59 |
-
background-color: var(--background);
|
| 60 |
-
color: var(--text);
|
| 61 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
.stApp {
|
| 65 |
-
background-color: var(--background);
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
.sidebar .sidebar-content {
|
| 69 |
-
background-color: var(--secondary-background);
|
| 70 |
-
border-right: 1px solid var(--border);
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
/* Headers */
|
| 74 |
-
h1, h2, h3 {
|
| 75 |
-
color: var(--primary);
|
| 76 |
-
font-weight: 600;
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
/* Center the main title */
|
| 80 |
-
h1 {
|
| 81 |
-
margin-bottom: 1.5rem;
|
| 82 |
-
font-size: 2.2rem;
|
| 83 |
-
text-align: center !important;
|
| 84 |
-
}
|
| 85 |
-
|
| 86 |
-
/* Add this for the title container */
|
| 87 |
-
[data-testid="stHeader"] {
|
| 88 |
-
text-align: center !important;
|
| 89 |
-
display: block;
|
| 90 |
-
width: 100%;
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
/* This ensures title text is centered */
|
| 94 |
-
.main .block-container [data-testid="stMarkdownContainer"] h1 {
|
| 95 |
-
text-align: center !important;
|
| 96 |
-
width: 100%;
|
| 97 |
-
display: block;
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
/* Form elements */
|
| 101 |
-
.stTextInput, .stNumberInput, .stSelectbox {
|
| 102 |
-
background-color: var(--secondary-background);
|
| 103 |
-
border-radius: 8px;
|
| 104 |
-
border: 1px solid var(--border);
|
| 105 |
-
box-shadow: 0 2px 4px var(--shadow);
|
| 106 |
-
margin-bottom: 1rem;
|
| 107 |
-
padding: 0.5rem;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
.stTextInput > div, .stNumberInput > div {
|
| 111 |
-
background-color: var(--secondary-background) !important;
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
.stTextInput input, .stNumberInput input {
|
| 115 |
-
color: var(--text) !important;
|
| 116 |
-
background-color: var(--secondary-background) !important;
|
| 117 |
-
border-radius: 4px;
|
| 118 |
-
padding: 0.75rem !important;
|
| 119 |
-
text-align: center;
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
/* Button styling */
|
| 123 |
-
.stButton > button {
|
| 124 |
-
background-color: var(--primary);
|
| 125 |
-
color: white !important;
|
| 126 |
-
border: none;
|
| 127 |
-
padding: 12px 28px;
|
| 128 |
-
border-radius: 6px;
|
| 129 |
-
font-weight: 500;
|
| 130 |
-
font-size: 1rem;
|
| 131 |
-
letter-spacing: 0.3px;
|
| 132 |
-
transition: all 0.2s ease;
|
| 133 |
-
box-shadow: 0 2px 5px var(--shadow);
|
| 134 |
-
width: 100%;
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
.stButton > button:hover {
|
| 138 |
-
background-color: var(--primary-hover);
|
| 139 |
-
transform: translateY(-2px);
|
| 140 |
-
box-shadow: 0 4px 8px var(--shadow);
|
| 141 |
-
}
|
| 142 |
-
|
| 143 |
-
.stButton > button:active {
|
| 144 |
-
transform: translateY(0);
|
| 145 |
-
box-shadow: 0 2px 4px var(--shadow);
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
/* Container styling */
|
| 149 |
-
.main .block-container {
|
| 150 |
-
padding: 2rem;
|
| 151 |
-
max-width: 1200px;
|
| 152 |
-
background-color: var(--secondary-background);
|
| 153 |
-
border-radius: 12px;
|
| 154 |
-
box-shadow: 0 4px 12px var(--shadow);
|
| 155 |
-
margin-top: 1rem;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
/* Labels */
|
| 159 |
-
label, .stRadio label {
|
| 160 |
-
color: var(--text) !important;
|
| 161 |
-
font-weight: 500;
|
| 162 |
-
margin-bottom: 0.5rem;
|
| 163 |
-
font-size: 1rem;
|
| 164 |
-
}
|
| 165 |
-
|
| 166 |
-
/* Result container */
|
| 167 |
-
.element-container {
|
| 168 |
-
background-color: var(--secondary-background);
|
| 169 |
-
border-radius: 8px;
|
| 170 |
-
border-left: 5px solid var(--primary);
|
| 171 |
-
}
|
| 172 |
-
|
| 173 |
-
/* Sidebar styling */
|
| 174 |
-
.css-1aumxhk, [data-testid="stSidebar"] {
|
| 175 |
-
background-color: var(--secondary-background);
|
| 176 |
-
border-right: 1px solid var(--border);
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] {
|
| 180 |
-
padding: 0.5rem 0;
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
/* Select box */
|
| 184 |
-
.stSelectbox div[data-baseweb="select"] {
|
| 185 |
-
background-color: var(--secondary-background);
|
| 186 |
-
border-color: var(--border);
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
/* Radio buttons - FIX HERE */
|
| 190 |
-
[role="radiogroup"] {
|
| 191 |
-
background-color: var(--secondary-background) !important;
|
| 192 |
-
padding: 0.5rem !important;
|
| 193 |
-
border-radius: 8px !important;
|
| 194 |
-
border: 1px solid var(--border) !important;
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
[data-baseweb="radio"] {
|
| 198 |
-
background-color: var(--secondary-background) !important;
|
| 199 |
-
margin: 0.25rem 0 !important;
|
| 200 |
-
}
|
| 201 |
-
|
| 202 |
-
[data-baseweb="radio"] input {
|
| 203 |
-
background-color: var(--secondary-background) !important;
|
| 204 |
-
}
|
| 205 |
-
|
| 206 |
-
[data-baseweb="radio"] div {
|
| 207 |
-
background-color: var(--secondary-background) !important;
|
| 208 |
-
}
|
| 209 |
-
|
| 210 |
-
/* The actual radio circle */
|
| 211 |
-
[data-baseweb="radio"] div:first-of-type {
|
| 212 |
-
border-color: var(--primary) !important;
|
| 213 |
-
}
|
| 214 |
-
|
| 215 |
-
/* The inner dot when selected */
|
| 216 |
-
[data-baseweb="radio"] div:first-of-type div {
|
| 217 |
-
background-color: var(--primary) !important;
|
| 218 |
-
}
|
| 219 |
-
|
| 220 |
-
/* The text label for the radio */
|
| 221 |
-
[data-baseweb="radio"] div:last-child {
|
| 222 |
-
color: var(--text) !important;
|
| 223 |
-
}
|
| 224 |
-
|
| 225 |
-
/* Column layout improvement */
|
| 226 |
-
.row-widget.stHorizontal {
|
| 227 |
-
gap: 1.5rem;
|
| 228 |
-
}
|
| 229 |
-
</style>
|
| 230 |
-
""", unsafe_allow_html=True)
|
| 231 |
-
|
| 232 |
-
else:
|
| 233 |
-
st.markdown(
|
| 234 |
-
"""
|
| 235 |
-
<style>
|
| 236 |
-
:root {
|
| 237 |
-
--primary: #4a8fe7;
|
| 238 |
-
--background: #2a2a2a;
|
| 239 |
-
--secondary-background: #444444;
|
| 240 |
-
--text: #ffffff;
|
| 241 |
-
--border: #555555;
|
| 242 |
-
--hover: #3a3a3a;
|
| 243 |
-
--shadow: rgba(0,0,0,0.3);
|
| 244 |
-
}
|
| 245 |
-
|
| 246 |
-
body {
|
| 247 |
-
background-color: var(--background);
|
| 248 |
-
color: var(--text);
|
| 249 |
-
}
|
| 250 |
-
|
| 251 |
-
.sidebar .sidebar-content {
|
| 252 |
-
background-color: var(--secondary-background);
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
-
.stTextInput, .stNumberInput, .stButton, .stTextArea {
|
| 256 |
-
background-color: var(--secondary-background);
|
| 257 |
-
color: var(--text);
|
| 258 |
-
border: 1px solid var(--border);
|
| 259 |
-
}
|
| 260 |
-
|
| 261 |
-
/* Center the main title in dark mode too */
|
| 262 |
-
h1 {
|
| 263 |
-
text-align: center !important;
|
| 264 |
-
width: 100%;
|
| 265 |
-
}
|
| 266 |
-
|
| 267 |
-
.main .block-container [data-testid="stMarkdownContainer"] h1 {
|
| 268 |
-
text-align: center !important;
|
| 269 |
-
}
|
| 270 |
-
</style>
|
| 271 |
-
""", unsafe_allow_html=True)
|
| 272 |
-
|
| 273 |
-
# العنوان
|
| 274 |
-
st.markdown(f"<h1>{texts['title']}</h1>", unsafe_allow_html=True)
|
| 275 |
-
|
| 276 |
-
# إدخال البيانات من المستخدم
|
| 277 |
-
col1, col2 = st.columns(2)
|
| 278 |
-
with col1:
|
| 279 |
-
temp = st.number_input(texts["temp"], value=30.0, key="temp_input")
|
| 280 |
-
humidity = st.number_input(texts["hum"], value=50.0, key="humidity_input")
|
| 281 |
-
with col2:
|
| 282 |
-
tds = st.number_input(texts["tds"], value=500.0, key="tds_input")
|
| 283 |
-
ph = st.number_input(texts["ph"], value=6.0, key="ph_input")
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
# زر التنبؤ
|
| 287 |
-
if st.button(texts["predict"], key="predict_button"):
|
| 288 |
-
# تجهيز البيانات بصيغة مناسبة للموديل
|
| 289 |
-
features = [[temp, humidity, tds, ph,]]
|
| 290 |
-
|
| 291 |
-
# توقع النتيجة باستخدام
|
| 292 |
-
prediction = model.predict(features)
|
| 293 |
-
|
| 294 |
-
# عرض النتيجة في صندوق نص
|
| 295 |
-
with st.container():
|
| 296 |
-
st.subheader(texts["result"])
|
| 297 |
-
st.markdown(
|
| 298 |
-
f"""
|
| 299 |
-
<div style="
|
| 300 |
-
background-color: var(--secondary-background);
|
| 301 |
-
color: var(--text);
|
| 302 |
-
border-radius: 8px;
|
| 303 |
-
padding: 20px;
|
| 304 |
-
border-left: 5px solid var(--primary);
|
| 305 |
-
margin: 16px 0;
|
| 306 |
-
box-shadow: 0 3px 8px var(--shadow);
|
| 307 |
-
text-align: center;
|
| 308 |
-
">
|
| 309 |
-
<h3 style="color: var(--primary); margin: 0; font-size: 1.4rem;">{prediction[0]}</h3>
|
| 310 |
-
</div>
|
| 311 |
-
""",
|
| 312 |
-
unsafe_allow_html=True
|
| 313 |
)
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import joblib
|
| 3 |
+
|
| 4 |
+
# تحميل الموديل
|
| 5 |
+
@st.cache_resource # حتى لا يعيد التحميل كل مرة
|
| 6 |
+
def load_model():
|
| 7 |
+
model = joblib.load("model2.joblib") # غيّر الاسم حسب اسم الملف
|
| 8 |
+
return model
|
| 9 |
+
|
| 10 |
+
model = load_model()
|
| 11 |
+
|
| 12 |
+
# اللغات
|
| 13 |
+
languages = {
|
| 14 |
+
"🇲🇦 العربية": {"title": "📊 توقع حالة النبات", "predict": "🔍 تنبؤ", "result": "🔍 النتيجة",
|
| 15 |
+
"temp": "درجة الحرارة (°C)", "hum": "الرطوبة (%)", "tds": "قيمة TDS (ppm)",
|
| 16 |
+
"ph": "مستوى pH", "days": "أيام النمو"},
|
| 17 |
+
"🇺🇸 English": {"title": "📊 Plant Status Prediction", "predict": "🔍 Predict", "result": "🔍 Result",
|
| 18 |
+
"temp": "Temperature (°C)", "hum": "Humidity (%)", "tds": "TDS Value (ppm)",
|
| 19 |
+
"ph": "pH Level", "days": "Growth Days"},
|
| 20 |
+
"🇫🇷 Français": {"title": "📊 Prédiction de l'État de la Plante", "predict": "🔍 Prédire", "result": "🔍 Résultat",
|
| 21 |
+
"temp": "Température (°C)", "hum": "Humidité (%)", "tds": "Valeur TDS (ppm)",
|
| 22 |
+
"ph": "Niveau pH", "days": "Jours de croissance"}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
# اختيار اللغة
|
| 26 |
+
language = st.sidebar.selectbox(
|
| 27 |
+
"🌍 اختر اللغة / Choose Language / Choisissez la langue",
|
| 28 |
+
list(languages.keys()),
|
| 29 |
+
key="language_selectbox" # إضافة مفتاح فريد
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
texts = languages[language]
|
| 33 |
+
|
| 34 |
+
# اختيار الوضع (Light or Dark Mode)
|
| 35 |
+
theme = st.sidebar.radio(
|
| 36 |
+
"🌙/🌞 اختر الوضع",
|
| 37 |
+
("Light Mode", "Dark Mode"),
|
| 38 |
+
key="theme_radio" # مفتاح فريد للوضع
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# تخصيص الألوان في الوضع الفاتح
|
| 42 |
+
if theme == "Light Mode":
|
| 43 |
+
st.markdown(
|
| 44 |
+
"""
|
| 45 |
+
<style>
|
| 46 |
+
:root {
|
| 47 |
+
--primary: #1e88e5;
|
| 48 |
+
--primary-hover: #1565c0;
|
| 49 |
+
--background: #f8f9fa;
|
| 50 |
+
--secondary-background: #ffffff;
|
| 51 |
+
--text: #212121;
|
| 52 |
+
--secondary-text: #616161;
|
| 53 |
+
--border: #e0e0e0;
|
| 54 |
+
--hover: #f5f5f5;
|
| 55 |
+
--shadow: rgba(0,0,0,0.1);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
body {
|
| 59 |
+
background-color: var(--background);
|
| 60 |
+
color: var(--text);
|
| 61 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.stApp {
|
| 65 |
+
background-color: var(--background);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.sidebar .sidebar-content {
|
| 69 |
+
background-color: var(--secondary-background);
|
| 70 |
+
border-right: 1px solid var(--border);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/* Headers */
|
| 74 |
+
h1, h2, h3 {
|
| 75 |
+
color: var(--primary);
|
| 76 |
+
font-weight: 600;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/* Center the main title */
|
| 80 |
+
h1 {
|
| 81 |
+
margin-bottom: 1.5rem;
|
| 82 |
+
font-size: 2.2rem;
|
| 83 |
+
text-align: center !important;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/* Add this for the title container */
|
| 87 |
+
[data-testid="stHeader"] {
|
| 88 |
+
text-align: center !important;
|
| 89 |
+
display: block;
|
| 90 |
+
width: 100%;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/* This ensures title text is centered */
|
| 94 |
+
.main .block-container [data-testid="stMarkdownContainer"] h1 {
|
| 95 |
+
text-align: center !important;
|
| 96 |
+
width: 100%;
|
| 97 |
+
display: block;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/* Form elements */
|
| 101 |
+
.stTextInput, .stNumberInput, .stSelectbox {
|
| 102 |
+
background-color: var(--secondary-background);
|
| 103 |
+
border-radius: 8px;
|
| 104 |
+
border: 1px solid var(--border);
|
| 105 |
+
box-shadow: 0 2px 4px var(--shadow);
|
| 106 |
+
margin-bottom: 1rem;
|
| 107 |
+
padding: 0.5rem;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.stTextInput > div, .stNumberInput > div {
|
| 111 |
+
background-color: var(--secondary-background) !important;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.stTextInput input, .stNumberInput input {
|
| 115 |
+
color: var(--text) !important;
|
| 116 |
+
background-color: var(--secondary-background) !important;
|
| 117 |
+
border-radius: 4px;
|
| 118 |
+
padding: 0.75rem !important;
|
| 119 |
+
text-align: center;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/* Button styling */
|
| 123 |
+
.stButton > button {
|
| 124 |
+
background-color: var(--primary);
|
| 125 |
+
color: white !important;
|
| 126 |
+
border: none;
|
| 127 |
+
padding: 12px 28px;
|
| 128 |
+
border-radius: 6px;
|
| 129 |
+
font-weight: 500;
|
| 130 |
+
font-size: 1rem;
|
| 131 |
+
letter-spacing: 0.3px;
|
| 132 |
+
transition: all 0.2s ease;
|
| 133 |
+
box-shadow: 0 2px 5px var(--shadow);
|
| 134 |
+
width: 100%;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.stButton > button:hover {
|
| 138 |
+
background-color: var(--primary-hover);
|
| 139 |
+
transform: translateY(-2px);
|
| 140 |
+
box-shadow: 0 4px 8px var(--shadow);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.stButton > button:active {
|
| 144 |
+
transform: translateY(0);
|
| 145 |
+
box-shadow: 0 2px 4px var(--shadow);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/* Container styling */
|
| 149 |
+
.main .block-container {
|
| 150 |
+
padding: 2rem;
|
| 151 |
+
max-width: 1200px;
|
| 152 |
+
background-color: var(--secondary-background);
|
| 153 |
+
border-radius: 12px;
|
| 154 |
+
box-shadow: 0 4px 12px var(--shadow);
|
| 155 |
+
margin-top: 1rem;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
/* Labels */
|
| 159 |
+
label, .stRadio label {
|
| 160 |
+
color: var(--text) !important;
|
| 161 |
+
font-weight: 500;
|
| 162 |
+
margin-bottom: 0.5rem;
|
| 163 |
+
font-size: 1rem;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/* Result container */
|
| 167 |
+
.element-container {
|
| 168 |
+
background-color: var(--secondary-background);
|
| 169 |
+
border-radius: 8px;
|
| 170 |
+
border-left: 5px solid var(--primary);
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/* Sidebar styling */
|
| 174 |
+
.css-1aumxhk, [data-testid="stSidebar"] {
|
| 175 |
+
background-color: var(--secondary-background);
|
| 176 |
+
border-right: 1px solid var(--border);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] {
|
| 180 |
+
padding: 0.5rem 0;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/* Select box */
|
| 184 |
+
.stSelectbox div[data-baseweb="select"] {
|
| 185 |
+
background-color: var(--secondary-background);
|
| 186 |
+
border-color: var(--border);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
/* Radio buttons - FIX HERE */
|
| 190 |
+
[role="radiogroup"] {
|
| 191 |
+
background-color: var(--secondary-background) !important;
|
| 192 |
+
padding: 0.5rem !important;
|
| 193 |
+
border-radius: 8px !important;
|
| 194 |
+
border: 1px solid var(--border) !important;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
[data-baseweb="radio"] {
|
| 198 |
+
background-color: var(--secondary-background) !important;
|
| 199 |
+
margin: 0.25rem 0 !important;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
[data-baseweb="radio"] input {
|
| 203 |
+
background-color: var(--secondary-background) !important;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
[data-baseweb="radio"] div {
|
| 207 |
+
background-color: var(--secondary-background) !important;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
/* The actual radio circle */
|
| 211 |
+
[data-baseweb="radio"] div:first-of-type {
|
| 212 |
+
border-color: var(--primary) !important;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
/* The inner dot when selected */
|
| 216 |
+
[data-baseweb="radio"] div:first-of-type div {
|
| 217 |
+
background-color: var(--primary) !important;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
/* The text label for the radio */
|
| 221 |
+
[data-baseweb="radio"] div:last-child {
|
| 222 |
+
color: var(--text) !important;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/* Column layout improvement */
|
| 226 |
+
.row-widget.stHorizontal {
|
| 227 |
+
gap: 1.5rem;
|
| 228 |
+
}
|
| 229 |
+
</style>
|
| 230 |
+
""", unsafe_allow_html=True)
|
| 231 |
+
|
| 232 |
+
else:
|
| 233 |
+
st.markdown(
|
| 234 |
+
"""
|
| 235 |
+
<style>
|
| 236 |
+
:root {
|
| 237 |
+
--primary: #4a8fe7;
|
| 238 |
+
--background: #2a2a2a;
|
| 239 |
+
--secondary-background: #444444;
|
| 240 |
+
--text: #ffffff;
|
| 241 |
+
--border: #555555;
|
| 242 |
+
--hover: #3a3a3a;
|
| 243 |
+
--shadow: rgba(0,0,0,0.3);
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
body {
|
| 247 |
+
background-color: var(--background);
|
| 248 |
+
color: var(--text);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.sidebar .sidebar-content {
|
| 252 |
+
background-color: var(--secondary-background);
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.stTextInput, .stNumberInput, .stButton, .stTextArea {
|
| 256 |
+
background-color: var(--secondary-background);
|
| 257 |
+
color: var(--text);
|
| 258 |
+
border: 1px solid var(--border);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
/* Center the main title in dark mode too */
|
| 262 |
+
h1 {
|
| 263 |
+
text-align: center !important;
|
| 264 |
+
width: 100%;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.main .block-container [data-testid="stMarkdownContainer"] h1 {
|
| 268 |
+
text-align: center !important;
|
| 269 |
+
}
|
| 270 |
+
</style>
|
| 271 |
+
""", unsafe_allow_html=True)
|
| 272 |
+
|
| 273 |
+
# العنوان
|
| 274 |
+
st.markdown(f"<h1>{texts['title']}</h1>", unsafe_allow_html=True)
|
| 275 |
+
|
| 276 |
+
# إدخال البيانات من المستخدم
|
| 277 |
+
col1, col2 = st.columns(2)
|
| 278 |
+
with col1:
|
| 279 |
+
temp = st.number_input(texts["temp"], value=30.0, key="temp_input")
|
| 280 |
+
humidity = st.number_input(texts["hum"], value=50.0, key="humidity_input")
|
| 281 |
+
with col2:
|
| 282 |
+
tds = st.number_input(texts["tds"], value=500.0, key="tds_input")
|
| 283 |
+
ph = st.number_input(texts["ph"], value=6.0, key="ph_input")
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
# زر التنبؤ
|
| 287 |
+
if st.button(texts["predict"], key="predict_button"):
|
| 288 |
+
# تجهيز البيانات بصيغة مناسبة للموديل
|
| 289 |
+
features = [[temp, humidity, tds, ph,]]
|
| 290 |
+
|
| 291 |
+
# توقع النتيجة باستخدام المودي��
|
| 292 |
+
prediction = model.predict(features)
|
| 293 |
+
|
| 294 |
+
# عرض النتيجة في صندوق نص
|
| 295 |
+
with st.container():
|
| 296 |
+
st.subheader(texts["result"])
|
| 297 |
+
st.markdown(
|
| 298 |
+
f"""
|
| 299 |
+
<div style="
|
| 300 |
+
background-color: var(--secondary-background);
|
| 301 |
+
color: var(--text);
|
| 302 |
+
border-radius: 8px;
|
| 303 |
+
padding: 20px;
|
| 304 |
+
border-left: 5px solid var(--primary);
|
| 305 |
+
margin: 16px 0;
|
| 306 |
+
box-shadow: 0 3px 8px var(--shadow);
|
| 307 |
+
text-align: center;
|
| 308 |
+
">
|
| 309 |
+
<h3 style="color: var(--primary); margin: 0; font-size: 1.4rem;">{prediction[0]}</h3>
|
| 310 |
+
</div>
|
| 311 |
+
""",
|
| 312 |
+
unsafe_allow_html=True
|
| 313 |
)
|