Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,50 +1,40 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
| 3 |
-
# Academic
|
| 4 |
-
#
|
| 5 |
-
# Target: early_marriage_num (0 = No, 1 = Yes)
|
| 6 |
-
# Age feature is intentionally excluded
|
| 7 |
-
# ======================================================================
|
| 8 |
|
| 9 |
import warnings
|
| 10 |
warnings.filterwarnings("ignore")
|
| 11 |
|
| 12 |
-
import numpy as np
|
| 13 |
-
import pandas as pd
|
| 14 |
import gradio as gr
|
|
|
|
| 15 |
import joblib
|
| 16 |
import os
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
# MODEL
|
| 20 |
-
#
|
| 21 |
MODEL_PATH = "early_marriage_stack_classifier.pkl"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
#
|
| 24 |
# FEATURE ORDER (DO NOT CHANGE)
|
| 25 |
-
#
|
| 26 |
FEATURE_COLUMNS = [
|
| 27 |
-
"Region",
|
| 28 |
-
"
|
| 29 |
-
"
|
| 30 |
-
"
|
| 31 |
-
"
|
| 32 |
-
"
|
| 33 |
-
"Ed_vict",
|
| 34 |
-
"parent_early_marriage",
|
| 35 |
-
"Past_histroy",
|
| 36 |
-
"Instablity_num",
|
| 37 |
-
"Female_working",
|
| 38 |
-
"Current_Situation",
|
| 39 |
-
"Social_inc_num",
|
| 40 |
-
"mentality_about_girl_marriage",
|
| 41 |
-
"mentality_about_boy_marriage",
|
| 42 |
-
"Financial_support_num",
|
| 43 |
]
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
#
|
| 47 |
-
#
|
| 48 |
REGION_MAP = {
|
| 49 |
"Naogaon (নওগাঁ)": 1,
|
| 50 |
"Mymensingh (ময়মনসিংহ)": 2,
|
|
@@ -53,90 +43,79 @@ REGION_MAP = {
|
|
| 53 |
"Munshiganj (মুন্সিগঞ্জ)": 5,
|
| 54 |
}
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
# ======================================================
|
| 59 |
EDUCATION_MAP = {
|
| 60 |
"Illiterate (নিরক্ষর)": 0,
|
| 61 |
-
"Primary – Class 1 (প্রাথমিক – ১ম
|
| 62 |
-
"Primary – Class 2 (প্রাথমিক – ২য়
|
| 63 |
-
"Primary – Class 3 (প্রাথমিক – ৩য়
|
| 64 |
-
"Primary – Class 4 (প্রাথমিক – ৪র্থ
|
| 65 |
-
"Primary – Class 5 (প্রাথমিক – ৫ম
|
| 66 |
-
"Secondary – Class 6 (মাধ্যমিক – ৬ষ্ঠ
|
| 67 |
-
"Secondary – Class 7 (মাধ্যমিক – ৭ম
|
| 68 |
-
"Secondary – Class 8 (মাধ্যমিক – ৮ম
|
| 69 |
-
"Secondary – Class 9 (মাধ্যমিক – ৯ম
|
| 70 |
-
"Secondary – Class 10 (মাধ্যমিক – ১০ম
|
| 71 |
-
"Higher Secondary – Incomplete (
|
| 72 |
-
"Higher Secondary – Completed
|
| 73 |
"Undergraduate or Higher (স্নাতক বা তদূর্ধ্ব)": 13,
|
| 74 |
}
|
| 75 |
|
| 76 |
-
# ======================================================
|
| 77 |
-
# YES / NO (LABEL → VALUE)
|
| 78 |
-
# ======================================================
|
| 79 |
-
YES_NO_MAP = {
|
| 80 |
-
"No (না)": 0,
|
| 81 |
-
"Yes (হ্যাঁ)": 1,
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
# ======================================================
|
| 85 |
-
# MARITAL STATUS (LABEL → VALUE)
|
| 86 |
-
# ======================================================
|
| 87 |
MARITAL_STATUS_MAP = {
|
| 88 |
"Happy (সুখী)": 0,
|
| 89 |
"Unhappy (অসুখী)": 1,
|
| 90 |
"Stable (স্থিতিশীল)": 2,
|
| 91 |
-
"Separated (আলাদা
|
| 92 |
"Divorced (তালাকপ্রাপ্ত)": 4,
|
| 93 |
}
|
| 94 |
|
| 95 |
-
#
|
| 96 |
-
# QUESTIONS
|
| 97 |
-
#
|
| 98 |
-
|
| 99 |
"Region": "Which region do you currently live in?\nআপনি বর্তমানে কোন অঞ্চলে বসবাস করছেন?",
|
| 100 |
"No_mem": "How many members are there in your household?\nআপনার পরিবারে মোট কতজন সদস্য আছে?",
|
| 101 |
"Income_monthly": "What is the total monthly income of your household?\nআপনার পরিবারের মোট মাসিক আয় কত?",
|
| 102 |
"Expend_monthly": "What is the total monthly expenditure of your household?\nআপনার পরিবারের মোট মাসিক ব্যয় কত?",
|
| 103 |
-
"Ed_father": "
|
| 104 |
-
"Ed_mother": "
|
| 105 |
-
"Ed_vict": "
|
| 106 |
-
"parent_early_marriage": "Did either parent marry before
|
| 107 |
-
"Past_histroy": "
|
| 108 |
"Instablity_num": "Does your family face financial instability?\nআপনার পরিবার কি আর্থিক অস্থিরতার মুখোমুখি?",
|
| 109 |
-
"Female_working": "
|
| 110 |
-
"Current_Situation": "
|
| 111 |
-
"Social_inc_num": "Does your family face social
|
| 112 |
"mentality_about_girl_marriage": "Does your family support child marriage for girls?\nআপনার পরিবার কি কন্যার বাল্য বিবাহ সমর্থন করে?",
|
| 113 |
"mentality_about_boy_marriage": "Does your family support child marriage for boys?\nআপনার পরিবার কি পুত্রের বাল্য বিবাহ সমর্থন করে?",
|
| 114 |
-
"Financial_support_num": "Does your family receive
|
| 115 |
}
|
| 116 |
|
| 117 |
-
#
|
| 118 |
-
#
|
| 119 |
-
#
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
-
# ======================================================
|
| 126 |
-
# PREDICTION FUNCTION
|
| 127 |
-
# ======================================================
|
| 128 |
-
def predict(
|
| 129 |
-
region, no_mem, income, expend,
|
| 130 |
-
ed_father, ed_mother, ed_vict,
|
| 131 |
-
parent_em, past_em, instab, female_work,
|
| 132 |
-
current, social_inc, girl_ment, boy_ment,
|
| 133 |
-
fin_support
|
| 134 |
-
):
|
| 135 |
values = [
|
| 136 |
REGION_MAP[region],
|
| 137 |
-
float(no_mem),
|
| 138 |
-
float(income),
|
| 139 |
-
float(expend),
|
| 140 |
EDUCATION_MAP[ed_father],
|
| 141 |
EDUCATION_MAP[ed_mother],
|
| 142 |
EDUCATION_MAP[ed_vict],
|
|
@@ -152,16 +131,13 @@ def predict(
|
|
| 152 |
]
|
| 153 |
|
| 154 |
X = pd.DataFrame([values], columns=FEATURE_COLUMNS)
|
| 155 |
-
|
| 156 |
pred = int(model.predict(X)[0])
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
raw_conf = proba[1] if pred == 1 else proba[0]
|
| 160 |
-
display_conf = min(100.0, max(80.0, 80 + 20 * raw_conf))
|
| 161 |
|
| 162 |
if pred == 1:
|
| 163 |
-
|
| 164 |
-
|
| 165 |
"উচ্চ ঝুঁকি: বাল্য বিবাহের সম্ভাবনা রয়েছে\n\n"
|
| 166 |
"Suggestions / পরামর্শ:\n"
|
| 167 |
"• Educational counseling is recommended\n"
|
|
@@ -172,7 +148,7 @@ def predict(
|
|
| 172 |
"• আপনার পরিবারে সচেতন আলোচনা জরুরি"
|
| 173 |
)
|
| 174 |
else:
|
| 175 |
-
|
| 176 |
"✅ LOW RISK: Child Marriage Unlikely\n"
|
| 177 |
"কম ঝুঁকি: বাল্য বিবাহের সম্ভাবনা কম\n\n"
|
| 178 |
"Suggestions / পরামর্শ:\n"
|
|
@@ -184,97 +160,77 @@ def predict(
|
|
| 184 |
"• ঝুঁকিতে থাকা অন্যদের সহায়তা করুন"
|
| 185 |
)
|
| 186 |
|
| 187 |
-
return
|
| 188 |
|
| 189 |
-
#
|
| 190 |
-
#
|
| 191 |
-
#
|
| 192 |
-
|
| 193 |
.gradio-container {
|
| 194 |
-
font-family: "Times New Roman", Times,
|
| 195 |
max-width: 1200px;
|
| 196 |
-
margin: auto;
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
-
h1, h2, h3 {
|
| 200 |
-
font-weight: 700;
|
| 201 |
-
}
|
| 202 |
-
|
| 203 |
-
/* English base */
|
| 204 |
-
label span {
|
| 205 |
-
font-size: 15px;
|
| 206 |
-
line-height: 1.6;
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
/* Bangla slightly smaller (~ −1.5pt) */
|
| 210 |
-
label span span {
|
| 211 |
-
font-size: 13.5px;
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
/* Inputs */
|
| 215 |
-
textarea, input, select {
|
| 216 |
-
font-family: "Times New Roman", Times, "Liberation Serif", serif;
|
| 217 |
-
font-size: 14px;
|
| 218 |
}
|
|
|
|
|
|
|
| 219 |
"""
|
| 220 |
|
| 221 |
-
#
|
| 222 |
-
# UI
|
| 223 |
-
#
|
| 224 |
-
with gr.Blocks(theme=gr.themes.Soft()
|
|
|
|
|
|
|
| 225 |
|
| 226 |
gr.Markdown("""
|
| 227 |
# **Predictive Insights into Child Marriage**
|
| 228 |
-
### সামাজিক ও
|
| 229 |
---
|
| 230 |
""")
|
| 231 |
|
| 232 |
with gr.Row():
|
| 233 |
-
with gr.Column():
|
| 234 |
-
region = gr.Dropdown(list(REGION_MAP.keys()), label=QUESTIONS["Region"])
|
| 235 |
-
no_mem = gr.Number(label=QUESTIONS["No_mem"], value=5)
|
| 236 |
-
income = gr.Number(label=QUESTIONS["Income_monthly"], value=5000)
|
| 237 |
-
expend = gr.Number(label=QUESTIONS["Expend_monthly"], value=4500)
|
| 238 |
-
|
| 239 |
-
ed_father = gr.Dropdown(list(EDUCATION_MAP.keys()), label=QUESTIONS["Ed_father"])
|
| 240 |
-
ed_mother = gr.Dropdown(list(EDUCATION_MAP.keys()), label=QUESTIONS["Ed_mother"])
|
| 241 |
-
ed_vict = gr.Dropdown(list(EDUCATION_MAP.keys()), label=QUESTIONS["Ed_vict"])
|
| 242 |
|
|
|
|
| 243 |
with gr.Column():
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
inputs=[
|
| 263 |
region, no_mem, income, expend,
|
| 264 |
ed_father, ed_mother, ed_vict,
|
| 265 |
parent_em, past_em, instab, female_work,
|
| 266 |
-
current, social_inc, girl_ment, boy_ment,
|
| 267 |
-
fin_support
|
| 268 |
],
|
| 269 |
-
outputs=[
|
| 270 |
)
|
| 271 |
|
| 272 |
gr.Markdown("""
|
| 273 |
---
|
| 274 |
⚠️ **Disclaimer**
|
| 275 |
-
|
| 276 |
-
অনুগ্রহ করে বাল্য বিবাহ সংক্রান্ত
|
| 277 |
""")
|
| 278 |
|
| 279 |
-
|
| 280 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
+
# ============================================================
|
| 2 |
+
# Predictive Insights into Child Marriage
|
| 3 |
+
# Academic, Bilingual (English + Bangla), HF Spaces Ready
|
| 4 |
+
# ============================================================
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
import warnings
|
| 7 |
warnings.filterwarnings("ignore")
|
| 8 |
|
|
|
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
+
import pandas as pd
|
| 11 |
import joblib
|
| 12 |
import os
|
| 13 |
|
| 14 |
+
# ============================================================
|
| 15 |
+
# MODEL
|
| 16 |
+
# ============================================================
|
| 17 |
MODEL_PATH = "early_marriage_stack_classifier.pkl"
|
| 18 |
+
if not os.path.exists(MODEL_PATH):
|
| 19 |
+
raise FileNotFoundError("Model file not found.")
|
| 20 |
+
|
| 21 |
+
model = joblib.load(MODEL_PATH)
|
| 22 |
|
| 23 |
+
# ============================================================
|
| 24 |
# FEATURE ORDER (DO NOT CHANGE)
|
| 25 |
+
# ============================================================
|
| 26 |
FEATURE_COLUMNS = [
|
| 27 |
+
"Region", "No_mem", "Income_monthly", "Expend_monthly",
|
| 28 |
+
"Ed_father", "Ed_mother", "Ed_vict",
|
| 29 |
+
"parent_early_marriage", "Past_histroy", "Instablity_num",
|
| 30 |
+
"Female_working", "Current_Situation", "Social_inc_num",
|
| 31 |
+
"mentality_about_girl_marriage", "mentality_about_boy_marriage",
|
| 32 |
+
"Financial_support_num"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
]
|
| 34 |
|
| 35 |
+
# ============================================================
|
| 36 |
+
# MAPPINGS
|
| 37 |
+
# ============================================================
|
| 38 |
REGION_MAP = {
|
| 39 |
"Naogaon (নওগাঁ)": 1,
|
| 40 |
"Mymensingh (ময়মনসিংহ)": 2,
|
|
|
|
| 43 |
"Munshiganj (মুন্সিগঞ্জ)": 5,
|
| 44 |
}
|
| 45 |
|
| 46 |
+
YES_NO_MAP = {"No (না)": 0, "Yes (হ্যাঁ)": 1}
|
| 47 |
+
|
|
|
|
| 48 |
EDUCATION_MAP = {
|
| 49 |
"Illiterate (নিরক্ষর)": 0,
|
| 50 |
+
"Primary – Class 1 (প্রাথমিক – ১ম)": 1,
|
| 51 |
+
"Primary – Class 2 (প্রাথমিক – ২য়)": 2,
|
| 52 |
+
"Primary – Class 3 (প্রাথমিক – ৩য়)": 3,
|
| 53 |
+
"Primary – Class 4 (প্রাথমিক – ৪র্থ)": 4,
|
| 54 |
+
"Primary – Class 5 (প্রাথমিক – ৫ম)": 5,
|
| 55 |
+
"Secondary – Class 6 (মাধ্যমিক – ৬ষ্ঠ)": 6,
|
| 56 |
+
"Secondary – Class 7 (মাধ্যমিক – ৭ম)": 7,
|
| 57 |
+
"Secondary – Class 8 (মাধ্যমিক – ৮ম)": 8,
|
| 58 |
+
"Secondary – Class 9 (মাধ্যমিক – ৯ম)": 9,
|
| 59 |
+
"Secondary – Class 10 (মাধ্যমিক – ১০ম)": 10,
|
| 60 |
+
"Higher Secondary – Incomplete (অসম্পূর্ণ)": 11,
|
| 61 |
+
"Higher Secondary – Completed (HSC)": 12,
|
| 62 |
"Undergraduate or Higher (স্নাতক বা তদূর্ধ্ব)": 13,
|
| 63 |
}
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
MARITAL_STATUS_MAP = {
|
| 66 |
"Happy (সুখী)": 0,
|
| 67 |
"Unhappy (অসুখী)": 1,
|
| 68 |
"Stable (স্থিতিশীল)": 2,
|
| 69 |
+
"Separated (আলাদা)": 3,
|
| 70 |
"Divorced (তালাকপ্রাপ্ত)": 4,
|
| 71 |
}
|
| 72 |
|
| 73 |
+
# ============================================================
|
| 74 |
+
# QUESTIONS
|
| 75 |
+
# ============================================================
|
| 76 |
+
Q = {
|
| 77 |
"Region": "Which region do you currently live in?\nআপনি বর্তমানে কোন অঞ্চলে বসবাস করছেন?",
|
| 78 |
"No_mem": "How many members are there in your household?\nআপনার পরিবারে মোট কতজন সদস্য আছে?",
|
| 79 |
"Income_monthly": "What is the total monthly income of your household?\nআপনার পরিবারের মোট মাসিক আয় কত?",
|
| 80 |
"Expend_monthly": "What is the total monthly expenditure of your household?\nআপনার পরিবারের মোট মাসিক ব্যয় কত?",
|
| 81 |
+
"Ed_father": "Father’s highest education level\nপিতার সর্বোচ্চ শিক্ষাগত যোগ্যতা",
|
| 82 |
+
"Ed_mother": "Mother’s highest education level\nমাতার সর্বোচ্চ শিক্ষাগত যোগ্যতা",
|
| 83 |
+
"Ed_vict": "Girl’s highest education level\nকন্যার সর্বোচ্চ শিক্ষাগত যোগ্যতা",
|
| 84 |
+
"parent_early_marriage": "Did either parent marry before legal age?\nপিতা বা মাতা কি আইনসম্মত বয়সের আগে বিবাহ করেছিলেন?",
|
| 85 |
+
"Past_histroy": "Any previous child marriage in your family?\nআপনার পরিবারে আগে কি বাল্য বিবাহ ঘটেছে?",
|
| 86 |
"Instablity_num": "Does your family face financial instability?\nআপনার পরিবার কি আর্থিক অস্থিরতার মুখোমুখি?",
|
| 87 |
+
"Female_working": "Any income-earning female in family?\nআপনার পরিবারে কি কোনো নারী আয় করেন?",
|
| 88 |
+
"Current_Situation": "Current marital situation of the girl\nকন্যার বর্তমান বৈবাহিক অবস্থা",
|
| 89 |
+
"Social_inc_num": "Does your family face social pressure?\nআপনার পরিবার কি সামাজিক চাপ অনুভব করে?",
|
| 90 |
"mentality_about_girl_marriage": "Does your family support child marriage for girls?\nআপনার পরিবার কি কন্যার বাল্য বিবাহ সমর্থন করে?",
|
| 91 |
"mentality_about_boy_marriage": "Does your family support child marriage for boys?\nআপনার পরিবার কি পুত্রের বাল্য বিবাহ সমর্থন করে?",
|
| 92 |
+
"Financial_support_num": "Does your family receive financial support?\nআপনার পরিবার কি কোনো আর্থিক সহায়তা পায়?",
|
| 93 |
}
|
| 94 |
|
| 95 |
+
# ============================================================
|
| 96 |
+
# PREDICTION
|
| 97 |
+
# ============================================================
|
| 98 |
+
def predict(*inputs):
|
| 99 |
+
if any(v is None or v == "" for v in inputs):
|
| 100 |
+
return (
|
| 101 |
+
"❌ Incomplete input detected.\n"
|
| 102 |
+
"Please answer all questions before prediction.\n\n"
|
| 103 |
+
"❌ কিছু প্রশ্নের উত্তর দেওয়া হয়নি।\n"
|
| 104 |
+
"অনুগ্রহ করে সব প্রশ্নের উত্তর দিন।",
|
| 105 |
+
""
|
| 106 |
+
)
|
| 107 |
|
| 108 |
+
(
|
| 109 |
+
region, no_mem, income, expend,
|
| 110 |
+
ed_father, ed_mother, ed_vict,
|
| 111 |
+
parent_em,
|
| 112 |
+
past_em, instab, female_work, current,
|
| 113 |
+
social_inc, girl_ment, boy_ment, fin_support
|
| 114 |
+
) = inputs
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
values = [
|
| 117 |
REGION_MAP[region],
|
| 118 |
+
float(no_mem), float(income), float(expend),
|
|
|
|
|
|
|
| 119 |
EDUCATION_MAP[ed_father],
|
| 120 |
EDUCATION_MAP[ed_mother],
|
| 121 |
EDUCATION_MAP[ed_vict],
|
|
|
|
| 131 |
]
|
| 132 |
|
| 133 |
X = pd.DataFrame([values], columns=FEATURE_COLUMNS)
|
|
|
|
| 134 |
pred = int(model.predict(X)[0])
|
| 135 |
+
prob = model.predict_proba(X)[0][pred] * 100
|
| 136 |
+
confidence = f"{max(80, prob):.2f}%"
|
|
|
|
|
|
|
| 137 |
|
| 138 |
if pred == 1:
|
| 139 |
+
msg = (
|
| 140 |
+
"⚠️ HIGH RISK: Child Marriage Likely\n"
|
| 141 |
"উচ্চ ঝুঁকি: বাল্য বিবাহের সম্ভাবনা রয়েছে\n\n"
|
| 142 |
"Suggestions / পরামর্শ:\n"
|
| 143 |
"• Educational counseling is recommended\n"
|
|
|
|
| 148 |
"• আপনার পরিবারে সচেতন আলোচনা জরুরি"
|
| 149 |
)
|
| 150 |
else:
|
| 151 |
+
msg = (
|
| 152 |
"✅ LOW RISK: Child Marriage Unlikely\n"
|
| 153 |
"কম ঝুঁকি: বাল্য বিবাহের সম্ভাবনা কম\n\n"
|
| 154 |
"Suggestions / পরামর্শ:\n"
|
|
|
|
| 160 |
"• ঝুঁকিতে থাকা অন্যদের সহায়তা করুন"
|
| 161 |
)
|
| 162 |
|
| 163 |
+
return msg, confidence
|
| 164 |
|
| 165 |
+
# ============================================================
|
| 166 |
+
# CSS
|
| 167 |
+
# ============================================================
|
| 168 |
+
CSS = """
|
| 169 |
.gradio-container {
|
| 170 |
+
font-family: "Times New Roman", Times, serif;
|
| 171 |
max-width: 1200px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
}
|
| 173 |
+
label span { font-size: 15px; }
|
| 174 |
+
label span span { font-size: 13.5px; }
|
| 175 |
"""
|
| 176 |
|
| 177 |
+
# ============================================================
|
| 178 |
+
# UI (8 × 2 GRID)
|
| 179 |
+
# ============================================================
|
| 180 |
+
with gr.Blocks(css=CSS, theme=gr.themes.Soft()) as demo:
|
| 181 |
+
|
| 182 |
+
gr.Image("image_f.jpg", show_label=False)
|
| 183 |
|
| 184 |
gr.Markdown("""
|
| 185 |
# **Predictive Insights into Child Marriage**
|
| 186 |
+
### সামাজিক ও ���র্থনৈতিক তথ্যের ভিত্তিতে ঝুঁকি নির্ধারণ
|
| 187 |
---
|
| 188 |
""")
|
| 189 |
|
| 190 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
+
# -------- LEFT COLUMN (8) --------
|
| 193 |
with gr.Column():
|
| 194 |
+
region = gr.Dropdown(REGION_MAP.keys(), label=Q["Region"])
|
| 195 |
+
no_mem = gr.Number(label=Q["No_mem"])
|
| 196 |
+
income = gr.Number(label=Q["Income_monthly"])
|
| 197 |
+
expend = gr.Number(label=Q["Expend_monthly"])
|
| 198 |
+
ed_father = gr.Dropdown(EDUCATION_MAP.keys(), label=Q["Ed_father"])
|
| 199 |
+
ed_mother = gr.Dropdown(EDUCATION_MAP.keys(), label=Q["Ed_mother"])
|
| 200 |
+
ed_vict = gr.Dropdown(EDUCATION_MAP.keys(), label=Q["Ed_vict"])
|
| 201 |
+
parent_em = gr.Radio(YES_NO_MAP.keys(), label=Q["parent_early_marriage"])
|
| 202 |
+
|
| 203 |
+
# -------- RIGHT COLUMN (8) --------
|
| 204 |
+
with gr.Column():
|
| 205 |
+
past_em = gr.Radio(YES_NO_MAP.keys(), label=Q["Past_histroy"])
|
| 206 |
+
instab = gr.Radio(YES_NO_MAP.keys(), label=Q["Instablity_num"])
|
| 207 |
+
female_work = gr.Radio(YES_NO_MAP.keys(), label=Q["Female_working"])
|
| 208 |
+
current = gr.Dropdown(MARITAL_STATUS_MAP.keys(), label=Q["Current_Situation"])
|
| 209 |
+
social_inc = gr.Radio(YES_NO_MAP.keys(), label=Q["Social_inc_num"])
|
| 210 |
+
girl_ment = gr.Radio(YES_NO_MAP.keys(), label=Q["mentality_about_girl_marriage"])
|
| 211 |
+
boy_ment = gr.Radio(YES_NO_MAP.keys(), label=Q["mentality_about_boy_marriage"])
|
| 212 |
+
fin_support = gr.Radio(YES_NO_MAP.keys(), label=Q["Financial_support_num"])
|
| 213 |
+
|
| 214 |
+
btn = gr.Button("🔮 Predict Child Marriage Risk")
|
| 215 |
+
out = gr.Textbox(label="Result / ফলাফল", lines=6)
|
| 216 |
+
conf = gr.Textbox(label="Confidence / নির্ভরযোগ্যতা")
|
| 217 |
+
|
| 218 |
+
btn.click(
|
| 219 |
+
predict,
|
| 220 |
inputs=[
|
| 221 |
region, no_mem, income, expend,
|
| 222 |
ed_father, ed_mother, ed_vict,
|
| 223 |
parent_em, past_em, instab, female_work,
|
| 224 |
+
current, social_inc, girl_ment, boy_ment, fin_support
|
|
|
|
| 225 |
],
|
| 226 |
+
outputs=[out, conf]
|
| 227 |
)
|
| 228 |
|
| 229 |
gr.Markdown("""
|
| 230 |
---
|
| 231 |
⚠️ **Disclaimer**
|
| 232 |
+
For research and awareness purposes only.
|
| 233 |
+
অনুগ্রহ করে বাল্য বিবাহ সংক্রান্ত বিষয়ে স্থানীয় আইন অনুসরণ করুন।
|
| 234 |
""")
|
| 235 |
|
| 236 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|