harry-stark commited on
Commit
202a9f4
1 Parent(s): 5e1fd7e

Refactor: New model and removed multilingual support

Browse files
Files changed (3) hide show
  1. app.py +1 -2
  2. examples.json +1 -1
  3. utils.py +7 -1
app.py CHANGED
@@ -3,10 +3,9 @@ from typing import Sequence
3
  import streamlit as st
4
  from hf_model import classifier_zero,load_model
5
  from utils import plot_result,examples_load
6
-
7
 
8
  classifier=load_model()
9
-
10
  ex_text,ex_labels=examples_load()
11
 
12
 
 
3
  import streamlit as st
4
  from hf_model import classifier_zero,load_model
5
  from utils import plot_result,examples_load
6
+ import json
7
 
8
  classifier=load_model()
 
9
  ex_text,ex_labels=examples_load()
10
 
11
 
examples.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
  "text":"The Democratic president had just signed into law the most significant infrastructure package in generations. And he had done it by bringing Democrats and Republicans together.",
3
- "labels":["Economy", "Politics", "Environment", "Entertainment"]
4
  }
 
1
  {
2
  "text":"The Democratic president had just signed into law the most significant infrastructure package in generations. And he had done it by bringing Democrats and Republicans together.",
3
+ "labels":"'Economy', 'Politics', 'Environment', 'Entertainment'"
4
  }
utils.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import numpy as np
3
  import plotly.express as px
 
4
  def plot_result(top_topics, scores):
5
  top_topics = np.array(top_topics)
6
  scores = np.array(scores)
@@ -14,4 +15,9 @@ def plot_result(top_topics, scores):
14
  color_continuous_scale='GnBu')
15
  fig.update(layout_coloraxis_showscale=False)
16
  fig.update_traces(texttemplate='%{text:0.1f}%', textposition='outside')
17
- st.plotly_chart(fig)
 
 
 
 
 
 
1
  import streamlit as st
2
  import numpy as np
3
  import plotly.express as px
4
+ import json
5
  def plot_result(top_topics, scores):
6
  top_topics = np.array(top_topics)
7
  scores = np.array(scores)
 
15
  color_continuous_scale='GnBu')
16
  fig.update(layout_coloraxis_showscale=False)
17
  fig.update_traces(texttemplate='%{text:0.1f}%', textposition='outside')
18
+ st.plotly_chart(fig)
19
+
20
+ def examples_load():
21
+ with open("examples.json") as f:
22
+ data=json.load(f)
23
+ return data['text'],data['labels']