zionia commited on
Commit
6b23fac
1 Parent(s): 1dd5bbf

added more css to make interface consistent

Browse files
Files changed (1) hide show
  1. app.py +34 -20
app.py CHANGED
@@ -28,11 +28,12 @@ def prediction(news):
28
  return preds_dict
29
 
30
  def file_prediction(file):
 
31
  if file.name.endswith('.csv'):
32
- df = pd.read_csv(file.name)
33
- news_list = df.iloc[:, 0].tolist()
34
  else:
35
- news_list = [file.read().decode('utf-8')] # Load plain text
36
 
37
  results = []
38
  for news in news_list:
@@ -46,21 +47,6 @@ gradio_ui = gr.Interface(
46
  description=f"Enter Setswana news article to see the category of the news.\n For this classification, the {MODEL_URL} model was used.",
47
  inputs=gr.Textbox(lines=10, label="Paste some Setswana news here"),
48
  outputs=gr.Label(num_top_classes=5, label="News categories probabilities"),
49
- theme="default",
50
- css="""
51
- body {
52
- background-color: white !important;
53
- color: black !important;
54
- }
55
- .gradio-container {
56
- background-color: white !important;
57
- color: black !important;
58
- }
59
- .gr-button {
60
- background-color: #f0f0f0 !important;
61
- color: black !important;
62
- }
63
- """
64
  )
65
 
66
  gradio_file_ui = gr.Interface(
@@ -69,9 +55,37 @@ gradio_file_ui = gr.Interface(
69
  description=f"Upload a text or CSV file with Setswana news articles. The first column in the CSV should contain the news text.",
70
  inputs=gr.File(label="Upload text or CSV file"),
71
  outputs=gr.Dataframe(headers=["News Text", "Category Predictions"], label="Predictions from file"),
72
- theme="default"
73
  )
74
 
75
  gradio_combined_ui = gr.TabbedInterface([gradio_ui, gradio_file_ui], ["Text Input", "File Upload"])
76
 
77
- gradio_combined_ui.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  return preds_dict
29
 
30
  def file_prediction(file):
31
+ # Load the file (CSV or text)
32
  if file.name.endswith('.csv'):
33
+ df = pd.read_csv(file.name)
34
+ news_list = df.iloc[:, 0].tolist()
35
  else:
36
+ news_list = [file.read().decode('utf-8')]
37
 
38
  results = []
39
  for news in news_list:
 
47
  description=f"Enter Setswana news article to see the category of the news.\n For this classification, the {MODEL_URL} model was used.",
48
  inputs=gr.Textbox(lines=10, label="Paste some Setswana news here"),
49
  outputs=gr.Label(num_top_classes=5, label="News categories probabilities"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  )
51
 
52
  gradio_file_ui = gr.Interface(
 
55
  description=f"Upload a text or CSV file with Setswana news articles. The first column in the CSV should contain the news text.",
56
  inputs=gr.File(label="Upload text or CSV file"),
57
  outputs=gr.Dataframe(headers=["News Text", "Category Predictions"], label="Predictions from file"),
 
58
  )
59
 
60
  gradio_combined_ui = gr.TabbedInterface([gradio_ui, gradio_file_ui], ["Text Input", "File Upload"])
61
 
62
+ css = """
63
+ body {
64
+ background-color: white !important;
65
+ color: black !important;
66
+ }
67
+
68
+ .gradio-container {
69
+ background-color: white !important;
70
+ color: black !important;
71
+ }
72
+
73
+ .gr-input, .gr-button, .gr-textbox, .gr-file, .gr-dataframe {
74
+ background-color: white !important;
75
+ color: black !important;
76
+ border-color: #ccc !important;
77
+ }
78
+
79
+ .gr-button {
80
+ background-color: #f0f0f0 !important;
81
+ color: black !important;
82
+ border: 1px solid #ccc !important;
83
+ }
84
+
85
+ .gr-dataframe th, .gr-dataframe td {
86
+ background-color: #f9f9f9 !important;
87
+ color: black !important;
88
+ }
89
+ """
90
+
91
+ gradio_combined_ui.launch(css=css)