Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -205,61 +205,42 @@ def predict_opinion(excel_file: gr.File):
|
|
| 205 |
"Tahmin Görüş Tipi": labels})
|
| 206 |
|
| 207 |
|
| 208 |
-
#
|
| 209 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue")) as demo:
|
| 210 |
gr.Markdown("# Denetçi Görüşü Tahmin Uygulaması")
|
| 211 |
|
| 212 |
-
# 1️⃣ Dosya
|
| 213 |
with gr.Row():
|
| 214 |
-
|
| 215 |
file_types=[".xlsx", ".xls", ".xlsm"],
|
| 216 |
-
label="
|
| 217 |
)
|
| 218 |
-
|
| 219 |
|
| 220 |
-
# 2️⃣ Örnek
|
| 221 |
gr.Examples(
|
| 222 |
examples=EXAMPLE_XLSX,
|
| 223 |
-
inputs=
|
| 224 |
label="💾 Örnek Dosyayı Deneyin",
|
| 225 |
cache_examples=False,
|
| 226 |
)
|
| 227 |
|
| 228 |
-
# 3️⃣
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
# 4️⃣ Çıktı tablosu
|
| 232 |
-
result_df = gr.Dataframe(
|
| 233 |
-
visible=False,
|
| 234 |
wrap=True,
|
| 235 |
-
show_label=False
|
|
|
|
| 236 |
)
|
| 237 |
|
| 238 |
-
#
|
| 239 |
-
gr.
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
max-height: none !important;
|
| 243 |
-
overflow: visible !important;
|
| 244 |
-
}
|
| 245 |
-
</style>
|
| 246 |
-
""")
|
| 247 |
-
|
| 248 |
-
# 6️⃣ Tahmin fonksiyonunu sarmalayan fonksiyon
|
| 249 |
-
def run_prediction(file):
|
| 250 |
-
loading_md.update(visible=True)
|
| 251 |
-
df = predict_opinion(file)
|
| 252 |
-
return (
|
| 253 |
-
gr.update(visible=False), # loading gizle
|
| 254 |
-
gr.update(value=df, visible=True) # tablo göster
|
| 255 |
-
)
|
| 256 |
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
outputs=[loading_md, result_df],
|
| 262 |
-
show_progress=True
|
| 263 |
)
|
| 264 |
|
| 265 |
if __name__ == "__main__":
|
|
|
|
| 205 |
"Tahmin Görüş Tipi": labels})
|
| 206 |
|
| 207 |
|
| 208 |
+
# ------------------------ Gradio UI ------------------------
|
| 209 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue")) as demo:
|
| 210 |
gr.Markdown("# Denetçi Görüşü Tahmin Uygulaması")
|
| 211 |
|
| 212 |
+
# 1️⃣ Üst: Dosya yükle ve buton
|
| 213 |
with gr.Row():
|
| 214 |
+
file_in = gr.File(
|
| 215 |
file_types=[".xlsx", ".xls", ".xlsm"],
|
| 216 |
+
label="Excel Yükleyin"
|
| 217 |
)
|
| 218 |
+
btn = gr.Button("Tahmin Et", variant="primary")
|
| 219 |
|
| 220 |
+
# 2️⃣ Örnek Excel dosyaları
|
| 221 |
gr.Examples(
|
| 222 |
examples=EXAMPLE_XLSX,
|
| 223 |
+
inputs=file_in,
|
| 224 |
label="💾 Örnek Dosyayı Deneyin",
|
| 225 |
cache_examples=False,
|
| 226 |
)
|
| 227 |
|
| 228 |
+
# 3️⃣ Çıktılar (başta görünmesin)
|
| 229 |
+
out_df = gr.Dataframe(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
wrap=True,
|
| 231 |
+
show_label=False,
|
| 232 |
+
visible=False # 🔥 Bu satır önemli
|
| 233 |
)
|
| 234 |
|
| 235 |
+
# 4️⃣ Tahmin fonksiyonu
|
| 236 |
+
def predict_opinion_with_visibility(excel_file: gr.File):
|
| 237 |
+
df_result = predict_opinion(excel_file) # senin mevcut fonksiyonun
|
| 238 |
+
return gr.update(value=df_result, visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
+
btn.click(
|
| 241 |
+
predict_opinion_with_visibility,
|
| 242 |
+
inputs=file_in,
|
| 243 |
+
outputs=out_df
|
|
|
|
|
|
|
| 244 |
)
|
| 245 |
|
| 246 |
if __name__ == "__main__":
|