msmaje commited on
Commit
7f71857
·
verified ·
1 Parent(s): f3b6548

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -117,6 +117,13 @@ def preview_dataset(uploaded_file, text_column, label_column):
117
  # Get the file path from the uploaded file
118
  file_path = uploaded_file.name if hasattr(uploaded_file, 'name') else uploaded_file
119
 
 
 
 
 
 
 
 
120
  df = pd.read_csv(file_path)
121
 
122
  preview_info = []
@@ -672,7 +679,7 @@ with gr.Blocks(title="BERT Complaint Classifier", theme=gr.themes.Soft()) as app
672
  with gr.Column(variant="panel"):
673
  gr.Markdown("### 🛠️ Training Configuration")
674
  with gr.Row():
675
- uploaded_file = gr.File(label="Upload Training CSV File", type="filepath", file_types=["csv"])
676
  preview_btn = gr.Button("Preview Dataset")
677
  preview_output = gr.Markdown("Dataset info will appear here")
678
 
@@ -739,7 +746,7 @@ with gr.Blocks(title="BERT Complaint Classifier", theme=gr.themes.Soft()) as app
739
 
740
  gr.Markdown("---")
741
 
742
- csv_file_input = gr.File(label="Upload CSV File", type="filepath", file_types=["csv"])
743
  csv_predict_btn = gr.Button("🔮 Predict All", variant="primary")
744
 
745
  csv_prediction_output = gr.Markdown("CSV prediction results will appear here")
 
117
  # Get the file path from the uploaded file
118
  file_path = uploaded_file.name if hasattr(uploaded_file, 'name') else uploaded_file
119
 
120
+ # Check if file exists and is CSV
121
+ if not os.path.exists(file_path):
122
+ return "❌ File not found. Please try uploading again."
123
+
124
+ if not file_path.lower().endswith('.csv'):
125
+ return "❌ Please upload a CSV file (.csv extension required)."
126
+
127
  df = pd.read_csv(file_path)
128
 
129
  preview_info = []
 
679
  with gr.Column(variant="panel"):
680
  gr.Markdown("### 🛠️ Training Configuration")
681
  with gr.Row():
682
+ uploaded_file = gr.File(label="Upload Training CSV File", type="filepath", file_types=[".csv"])
683
  preview_btn = gr.Button("Preview Dataset")
684
  preview_output = gr.Markdown("Dataset info will appear here")
685
 
 
746
 
747
  gr.Markdown("---")
748
 
749
+ csv_file_input = gr.File(label="Upload CSV File", type="filepath", file_types=[".csv"])
750
  csv_predict_btn = gr.Button("🔮 Predict All", variant="primary")
751
 
752
  csv_prediction_output = gr.Markdown("CSV prediction results will appear here")