rshakked commited on
Commit
758b108
Β·
1 Parent(s): 980da81

Add a viewer to your Gradio app to see evaluation results

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -5,7 +5,7 @@ from train_abuse_model import (
5
  push_model_to_hub
6
  )
7
  from predict_pipeline import run_prediction_pipeline
8
- from pathlib import Path
9
 
10
  with gr.Blocks() as demo:
11
  gr.Markdown("## 🧠 Abuse Detection App")
@@ -34,9 +34,18 @@ with gr.Blocks() as demo:
34
  inputs=[desc_input, chat_upload],
35
  outputs=[enriched_output, label_output]
36
  )
 
 
 
 
 
 
 
 
 
 
 
37
 
38
- with gr.Tab("πŸ“‚ Files"):
39
- files_list = gr.FileExplorer(value=str(Path("/home/user/app")), label="Browse Saved Files")
40
 
41
  if __name__ == "__main__":
42
  demo.launch()
 
5
  push_model_to_hub
6
  )
7
  from predict_pipeline import run_prediction_pipeline
8
+
9
 
10
  with gr.Blocks() as demo:
11
  gr.Markdown("## 🧠 Abuse Detection App")
 
34
  inputs=[desc_input, chat_upload],
35
  outputs=[enriched_output, label_output]
36
  )
37
+ with gr.Tab("πŸ“Š Evaluation Viewer"):
38
+ file_selector = gr.File(label="Select a report file")
39
+ preview_box = gr.Textbox(label="πŸ“„ File Preview", lines=20)
40
+
41
+ def load_eval_file(file_obj):
42
+ if file_obj is None:
43
+ return "No file selected."
44
+ with open(file_obj.name, encoding="utf-8") as f:
45
+ return f.read()
46
+
47
+ file_selector.change(load_eval_file, inputs=file_selector, outputs=preview_box)
48
 
 
 
49
 
50
  if __name__ == "__main__":
51
  demo.launch()