Spaces:
Sleeping
Sleeping
File size: 5,817 Bytes
ece3b1a 4316a60 7eb8d3b 4316a60 ece3b1a 7eb8d3b 4316a60 7eb8d3b 5aa1b8c ece3b1a 5aa1b8c ece3b1a 5aa1b8c 4316a60 ece3b1a 4de73ea 4316a60 ece3b1a 4316a60 ece3b1a 4316a60 7eb8d3b 4316a60 ece3b1a 5aa1b8c 4316a60 ece3b1a 4316a60 ece3b1a 4de73ea dfa76ef ece3b1a 5aa1b8c 7eb8d3b 5aa1b8c dfa76ef 4316a60 ece3b1a 4316a60 7eb8d3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# app.py - کاتب 2025 Edition — تم خفن، سریع و بدون ارور
import gradio as gr
from catboost import CatBoostRegressor
# لود مدل (26 مگ = فوق سریع)
model = CatBoostRegressor()
model.load_model("kaatib_v8_optimized.cbm")
def predict(area_type, area, rooms, neighborhood, elevator, parking, warehouse, age):
effective_area = area if area_type == "متراژ مفید (معمول در دیوار)" else area * 0.87
pred = model.predict([[
effective_area,
__import__("numpy").log1p(effective_area),
rooms, age, 1 if age <= 5 else 0,
neighborhood.strip(), int(elevator), int(parking), int(warehouse)
]])[0] / 1_000_000_000
return f"""
<div class="result-card">
<h2>{pred:.2f} میلیارد تومان</h2>
<p>رنج واقعی بازار: {(pred*0.88):.2f} – {(pred*1.15):.2f} میلیارد</p>
</div>
"""
# تم 2025 — سفید + نئون طلایی
css = """
<style>
:root {
--primary: #d4af37;
--bg: #ffffff;
--text: #1a1a1a;
--gray: #666666;
}
.gradio-container {
max-width: 920px !important;
margin: 20px auto !important;
background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%) !important;
border-radius: 28px !important;
box-shadow: 0 20px 60px rgba(0,0,0,0.08) !important;
padding: 30px !important;
direction: rtl !important;
font-family: 'Vazir', system-ui, sans-serif !important;
}
body {background: #f0f4f8 !important;}
/* هدر خفن */
.header {
text-align: center;
padding: 50px 20px;
background: linear-gradient(135deg, #0d2b1f 0%, #1e4d38 100%);
border-radius: 24px;
margin-bottom: 35px;
color: white;
}
.header h1 {
font-size: 68px;
margin: 0;
color: #d4af37;
text-shadow: 0 0 40px rgba(212,175,55,0.6);
}
/* کارتهای ورودی */
.gr-form {
background: white !important;
padding: 24px !important;
border-radius: 20px !important;
box-shadow: 0 8px 30px rgba(0,0,0,0.06) !important;
margin-bottom: 20px;
}
/* لیبلها */
label {
color: var(--text) !important;
font-weight: 600 !important;
font-size: 16px !important;
}
/* باکسها */
.gr-textbox, .gr-dropdown, .gr-slider > div {
background: white !important;
border: 2px solid #e2e8f0 !important;
border-radius: 16px !important;
color: var(--gray) !important;
}
.gr-textbox input::placeholder {color: #94a3b8 !important;}
/* چکباکس و رادیو */
.gr-checkbox, .gr-radio {
background: white !important;
border: 2px solid var(--primary) !important;
border-radius: 12px !important;
}
/* دکمه طلایی با انیمیشن */
.gr-button {
background: linear-gradient(45deg, #d4af37, #f4d03f) !important;
color: black !important;
font-weight: bold !important;
font-size: 22px !important;
padding: 18px !important;
border-radius: 18px !important;
box-shadow: 0 10px 30px rgba(212,175,55,0.4) !important;
transition: all 0.3s ease !important;
}
.gr-button:hover {
transform: translateY(-4px) scale(1.02);
box-shadow: 0 20px 40px rgba(212,175,55,0.6) !important;
}
/* نتیجه */
.result-card {
text-align: center;
padding: 40px;
background: linear-gradient(135deg, #0d2b1f, #1e4d38);
border-radius: 24px;
border: 4px solid var(--primary);
color: white;
animation: fadeIn 0.8s ease;
}
.result-card h2 {
font-size: 52px;
color: #d4af37;
margin: 10px 0;
}
@keyframes fadeIn {from {opacity:0; transform:translateY(20px)} to {opacity:1; transform:translateY(0)}}
</style>
"""
with gr.Blocks(css=css, title="کاتب 2025 - قیمت آپارتمان تهران") as app:
gr.HTML(css)
gr.HTML("""
<div class="header">
<h1>کاتب</h1>
<p style="font-size:28px;margin:15px 0 5px">هوش مصنوعی پیشبینی قیمت مسکن تهران</p>
<p style="font-size:20px;color:#a0d8c8">۸۱,۰۰۰ آگهی واقعی دیوار ۱۴۰۴</p>
</div>
""")
with gr.Row():
area_type = gr.Radio(["متراژ مفید (معمول در دیوار)", "متراژ سندی"],
value="متراژ مفید (معمول در دیوار)", label="نوع متراژ")
with gr.Row():
area = gr.Slider(40, 450, 90, step=1, label="متراژ")
rooms = gr.Dropdown([1,2,3,4,5,6], value=3, label="تعداد خواب")
neighborhood = gr.Textbox(placeholder="مثل: سعادت آباد، نیاوران، پونک، جردن...", label="محله")
with gr.Row():
elevator = gr.Checkbox(label="آسانسور", value=True)
parking = gr.Checkbox(label="پارکینگ", value=True)
warehouse = gr.Checkbox(label="انباری", value=True)
age = gr.Slider(0, 50, 8, step=1, label="سن بنا (سال)")
gr.Button("پیشبینی قیمت", variant="primary").click(
predict,
inputs=[area_type, area, rooms, neighborhood, elevator, parking, warehouse, age],
outputs=gr.Markdown()
)
gr.HTML("""
<div style="text-align:center;margin-top:50px;padding:35px;background:white;border-radius:20px;box-shadow:0 8px 30px rgba(0,0,0,0.08);border:2px dashed #d4af37">
<p style="color:#d4af37;font-size:26px;margin:0">ساخته شده با افتخار در ایران</p>
</div>
""")
app.launch() |