Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
# app.py - نسخه نهایی و
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
from catboost import CatBoostRegressor
|
| 6 |
|
| 7 |
-
# لود مدل بهینه
|
| 8 |
model = CatBoostRegressor()
|
| 9 |
model.load_model("kaatib_v8_optimized.cbm")
|
| 10 |
|
|
@@ -34,40 +34,130 @@ def predict(area_type, area, rooms, neighborhood, elevator, parking, warehouse,
|
|
| 34 |
</div>
|
| 35 |
"""
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
with gr.Blocks(title="کاتب - قیمت آپارتمان تهران ۱۴۰۴") as app:
|
|
|
|
|
|
|
|
|
|
| 38 |
gr.HTML("""
|
| 39 |
-
<style>
|
| 40 |
-
.gradio-container {max-width: 960px !important; margin: 20px auto; background: linear-gradient(135deg, #0a1e15, #0f2b1f); border-radius: 30px; box-shadow: 0 30px 80px rgba(0,0,0,0.95); padding: 20px;}
|
| 41 |
-
body {background: #040a07 !important;}
|
| 42 |
-
label {color: black !important; font-weight: bold !important; background: white !important; padding: 12px 20px !important; border-radius: 16px !important;}
|
| 43 |
-
.gr-button {background: linear-gradient(45deg, #d4af37, #b8971a) !important; color: black !important; font-size: 24px !important; padding: 20px !important; border-radius: 20px !important;}
|
| 44 |
-
</style>
|
| 45 |
-
<div style="text-align:center; padding:60px 20px; background:linear-gradient(135deg,#0d2b1f,#1e4d38); border-bottom:6px solid #d4af37;">
|
| 46 |
<h1 style="font-size:70px; margin:0; color:#d4af37; text-shadow:0 0 40px #d4af3777;">کاتب</h1>
|
| 47 |
-
<p style="font-size:34px; color:#b8d5cd;">هوش مصنوعی پیشبینی قیمت مسکن تهران</p>
|
| 48 |
<p style="font-size:24px; color:#8fb8a2;">۸۱,۰۰۰ آگهی واقعی دیوار ۱۴۰۴</p>
|
| 49 |
</div>
|
| 50 |
""")
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
with gr.Row():
|
| 54 |
-
area = gr.Slider(40, 450, 90, step=1, label="متراژ")
|
| 55 |
rooms = gr.Dropdown([1,2,3,4,5,6], value=3, label="تعداد خواب")
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
with gr.Row():
|
| 58 |
elevator = gr.Checkbox(label="آسانسور", value=True)
|
| 59 |
parking = gr.Checkbox(label="پارکینگ", value=True)
|
| 60 |
warehouse = gr.Checkbox(label="انباری", value=True)
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
|
|
|
| 64 |
inputs=[area_type, area, rooms, neighborhood, elevator, parking, warehouse, age],
|
| 65 |
-
outputs=
|
|
|
|
| 66 |
|
|
|
|
| 67 |
gr.HTML("""
|
| 68 |
-
<div style="text-align:center; margin:60px; padding:40px; background:rgba(212,175,55,0.15); border-radius:25px; border:3px dashed #d4af37;">
|
| 69 |
-
<p style="color:#d4af37; font-size:26px;">ساخته شده با افتخار در ایران</p>
|
| 70 |
</div>
|
| 71 |
""")
|
| 72 |
|
|
|
|
| 73 |
app.launch()
|
|
|
|
| 1 |
+
# app.py - نسخه نهایی کاتب با فونت ۱۰۰٪ مشکی و خوانا (مخصوص Hugging Face Spaces)
|
| 2 |
import gradio as gr
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
from catboost import CatBoostRegressor
|
| 6 |
|
| 7 |
+
# لود مدل بهینه (فایل kaatib_v8_optimized.cbm باید آپلود شده باشه)
|
| 8 |
model = CatBoostRegressor()
|
| 9 |
model.load_model("kaatib_v8_optimized.cbm")
|
| 10 |
|
|
|
|
| 34 |
</div>
|
| 35 |
"""
|
| 36 |
|
| 37 |
+
# CSS کامل با فونت ۱۰۰٪ مشکی و خوانا
|
| 38 |
+
css = """
|
| 39 |
+
<style>
|
| 40 |
+
/* پسزمینه اصلی */
|
| 41 |
+
.gradio-container {
|
| 42 |
+
max-width: 960px !important;
|
| 43 |
+
margin: 20px auto !important;
|
| 44 |
+
background: linear-gradient(135deg, #0a1e15, #0f2b1f);
|
| 45 |
+
border-radius: 30px;
|
| 46 |
+
box-shadow: 0 30px 80px rgba(0,0,0,0.95);
|
| 47 |
+
padding: 20px;
|
| 48 |
+
}
|
| 49 |
+
body {background: #040a07 !important;}
|
| 50 |
+
|
| 51 |
+
/* تمام لیبلها و متنهای بالای ورودیها */
|
| 52 |
+
label, .gr-form label, .gr-block-title {
|
| 53 |
+
color: black !important;
|
| 54 |
+
font-weight: bold !important;
|
| 55 |
+
background: white !important;
|
| 56 |
+
padding: 12px 20px !important;
|
| 57 |
+
border-radius: 16px !important;
|
| 58 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/* رادیو و چکباکس */
|
| 62 |
+
.gr-radio label, .gr-checkbox label,
|
| 63 |
+
.gr-radio > div > label, .gr-checkbox > div > label {
|
| 64 |
+
color: black !important;
|
| 65 |
+
background: white !important;
|
| 66 |
+
padding: 10px 18px !important;
|
| 67 |
+
border-radius: 12px !important;
|
| 68 |
+
border: 2px solid #d4af37 !important;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/* اسلایدر (اعداد، خط و دکمه) */
|
| 72 |
+
.gr-slider input[type="range"],
|
| 73 |
+
.gr-slider .track,
|
| 74 |
+
.gr-slider .thumb,
|
| 75 |
+
.gr-slider div[role="slider"],
|
| 76 |
+
.gr-slider > div > div > div,
|
| 77 |
+
.gr-slider input[type="range"] + div {
|
| 78 |
+
color: black !important;
|
| 79 |
+
background: white !important;
|
| 80 |
+
font-weight: bold !important;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/* دراپداون (تعداد خواب) */
|
| 84 |
+
.gr-dropdown, .gr-dropdown > div {
|
| 85 |
+
background: white !important;
|
| 86 |
+
color: black !important;
|
| 87 |
+
border-radius: 16px !important;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/* تکستباکس (محله) */
|
| 91 |
+
.gr-textbox {
|
| 92 |
+
background: white !important;
|
| 93 |
+
color: black !important;
|
| 94 |
+
border-radius: 16px !important;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/* دکمه اصلی */
|
| 98 |
+
.gr-button {
|
| 99 |
+
background: linear-gradient(45deg, #d4af37, #b8971a) !important;
|
| 100 |
+
color: black !important;
|
| 101 |
+
font-size: 24px !important;
|
| 102 |
+
padding: 22px !important;
|
| 103 |
+
border-radius: 20px !important;
|
| 104 |
+
font-weight: bold !important;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/* مطمئن بشیم هیچ متنی سفید نباشه */
|
| 108 |
+
* { color: black !important; }
|
| 109 |
+
input, select, textarea, .gr-form *, span, div { color: black !important; }
|
| 110 |
+
</style>
|
| 111 |
+
"""
|
| 112 |
+
|
| 113 |
with gr.Blocks(title="کاتب - قیمت آپارتمان تهران ۱۴۰۴") as app:
|
| 114 |
+
gr.HTML(css) # CSS رو اول لود میکنیم
|
| 115 |
+
|
| 116 |
+
# هدر طلایی
|
| 117 |
gr.HTML("""
|
| 118 |
+
<div style="text-align:center; padding:60px 20px; background:linear-gradient(135deg,#0d2b1f,#1e4d38); border-bottom:6px solid #d4af37; border-radius:25px 25px 0 0;">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
<h1 style="font-size:70px; margin:0; color:#d4af37; text-shadow:0 0 40px #d4af3777;">کاتب</h1>
|
| 120 |
+
<p style="font-size:34px; color:#b8d5cd; margin:10px 0 5px;">هوش مصنوعی پیشبینی قیمت مسکن تهران</p>
|
| 121 |
<p style="font-size:24px; color:#8fb8a2;">۸۱,۰۰۰ آگهی واقعی دیوار ۱۴۰۴</p>
|
| 122 |
</div>
|
| 123 |
""")
|
| 124 |
|
| 125 |
+
# ورودیها
|
| 126 |
+
area_type = gr.Radio(
|
| 127 |
+
["متراژ مفید (معمول در دیوار)", "متراژ سندی"],
|
| 128 |
+
value="متراژ مفید (معمول در دیوار)",
|
| 129 |
+
label="نوع متراژ"
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
with gr.Row():
|
| 133 |
+
area = gr.Slider(40, 450, value=90, step=1, label="متراژ")
|
| 134 |
rooms = gr.Dropdown([1,2,3,4,5,6], value=3, label="تعداد خواب")
|
| 135 |
+
|
| 136 |
+
neighborhood = gr.Textbox(placeholder="مثل: سعادت آباد، پونک، نیاوران، زعفرانیه، جردن...", label="محله")
|
| 137 |
+
|
| 138 |
with gr.Row():
|
| 139 |
elevator = gr.Checkbox(label="آسانسور", value=True)
|
| 140 |
parking = gr.Checkbox(label="پارکینگ", value=True)
|
| 141 |
warehouse = gr.Checkbox(label="انباری", value=True)
|
| 142 |
+
|
| 143 |
+
age = gr.Slider(0, 50, value=8, step=1, label="سن بنا (سال)")
|
| 144 |
+
|
| 145 |
+
# دکمه و خروجی
|
| 146 |
+
btn = gr.Button("پیشبینی قیمت", variant="primary")
|
| 147 |
+
output = gr.Markdown()
|
| 148 |
|
| 149 |
+
btn.click(
|
| 150 |
+
fn=predict,
|
| 151 |
inputs=[area_type, area, rooms, neighborhood, elevator, parking, warehouse, age],
|
| 152 |
+
outputs=output
|
| 153 |
+
)
|
| 154 |
|
| 155 |
+
# فوتر
|
| 156 |
gr.HTML("""
|
| 157 |
+
<div style="text-align:center; margin:60px 20px 20px; padding:40px; background:rgba(212,175,55,0.15); border-radius:25px; border:3px dashed #d4af37;">
|
| 158 |
+
<p style="color:#d4af37; font-size:26px; margin:0;">ساخته شده با افتخار در ایران</p>
|
| 159 |
</div>
|
| 160 |
""")
|
| 161 |
|
| 162 |
+
# لانچ
|
| 163 |
app.launch()
|