Ginidu2003 commited on
Commit
a04138a
·
verified ·
1 Parent(s): 939dc02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -31,12 +31,13 @@ def preprocess_text(text):
31
  return ' '.join(tokens)
32
 
33
 
34
- classifier_model = "Ginidu2003/Distilbert-Base-News-classifier"
35
 
36
 
37
 
38
 
39
  # ====================== CLASSIFICATION FUNCTION ======================
 
40
  @torch.no_grad()
41
  def classify_csv(file):
42
  try:
@@ -95,7 +96,7 @@ def create_colored_bar_chart(category_counts):
95
  ax.text(bar.get_x() + bar.get_width()/2, height + 0.5,
96
  str(int(height)), ha='center', va='bottom', fontsize=12, fontweight='bold')
97
 
98
- ax.set_title("Category Distribution Across 5 Classes", fontsize=14, fontweight='bold')
99
  ax.set_xlabel("Category")
100
  ax.set_ylabel("Count")
101
  plt.xticks(rotation=15)
@@ -135,9 +136,9 @@ def answer_question(news_content, question):
135
  return f"Error: {str(e)}"
136
 
137
  # ====================== GRADIO INTERFACE ======================
138
- with gr.Blocks(title=" News Classifier & Question Answering App") as demo:
139
- gr.Markdown("# 📰 English News Classifier")
140
- #gr.Markdown("### Section 02 - Text Analytics Assignment")
141
 
142
  with gr.Tabs():
143
  with gr.Tab("📊 News Classification"):
@@ -147,7 +148,7 @@ with gr.Blocks(title=" News Classifier & Question Answering App") as demo:
147
  output_text = gr.Textbox(label="Status")
148
  output_file = gr.File(label="Download output.csv")
149
  bar_chart = gr.Plot(
150
- label="Category Distribution Across 5 Classes"
151
 
152
 
153
  )
@@ -171,6 +172,6 @@ with gr.Blocks(title=" News Classifier & Question Answering App") as demo:
171
  outputs=qa_output
172
  )
173
 
174
- #gr.Markdown("Built for Text Analytics Assignment - Section 02")
175
 
176
  demo.launch()
 
31
  return ' '.join(tokens)
32
 
33
 
34
+
35
 
36
 
37
 
38
 
39
  # ====================== CLASSIFICATION FUNCTION ======================
40
+ classifier_model = "Ginidu2003/Distilbert-Base-News-classifier"
41
  @torch.no_grad()
42
  def classify_csv(file):
43
  try:
 
96
  ax.text(bar.get_x() + bar.get_width()/2, height + 0.5,
97
  str(int(height)), ha='center', va='bottom', fontsize=12, fontweight='bold')
98
 
99
+ ax.set_title("News Category Distribution Across 5 Classes", fontsize=14, fontweight='bold')
100
  ax.set_xlabel("Category")
101
  ax.set_ylabel("Count")
102
  plt.xticks(rotation=15)
 
136
  return f"Error: {str(e)}"
137
 
138
  # ====================== GRADIO INTERFACE ======================
139
+ with gr.Blocks(title="News Classifier & Question Answering App..") as demo:
140
+ gr.Markdown("# 📰 News Classifier & Question Answering App..")
141
+
142
 
143
  with gr.Tabs():
144
  with gr.Tab("📊 News Classification"):
 
148
  output_text = gr.Textbox(label="Status")
149
  output_file = gr.File(label="Download output.csv")
150
  bar_chart = gr.Plot(
151
+ label="News Category Distribution Across 5 Classes"
152
 
153
 
154
  )
 
172
  outputs=qa_output
173
  )
174
 
175
+
176
 
177
  demo.launch()