buraktrk commited on
Commit
6af7eb6
·
verified ·
1 Parent(s): 5d42a5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -38
app.py CHANGED
@@ -205,61 +205,42 @@ def predict_opinion(excel_file: gr.File):
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️⃣ Dosya yükleme ve buton
213
  with gr.Row():
214
- file_input = gr.File(
215
  file_types=[".xlsx", ".xls", ".xlsm"],
216
- label="📂 Excel Dosyası Yükleyin"
217
  )
218
- predict_btn = gr.Button("Tahmin Et", variant="primary")
219
 
220
- # 2️⃣ Örnek dosyalar
221
  gr.Examples(
222
  examples=EXAMPLE_XLSX,
223
- inputs=file_input,
224
  label="💾 Örnek Dosyayı Deneyin",
225
  cache_examples=False,
226
  )
227
 
228
- # 3️⃣ Yükleniyor mesajı
229
- loading_md = gr.Markdown("⏳ Tahmin ediliyor...", visible=False)
230
-
231
- # 4️⃣ Çıktı tablosu
232
- result_df = gr.Dataframe(
233
- visible=False,
234
  wrap=True,
235
- show_label=False
 
236
  )
237
 
238
- # 5️⃣ Scroll çubuğunu CSS ile gizle
239
- gr.HTML("""
240
- <style>
241
- .scroll-hide table {
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
- # 7️⃣ Butona tıklama olayı
258
- predict_btn.click(
259
- fn=run_prediction,
260
- inputs=file_input,
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__":