harry-stark commited on
Commit
bad8793
1 Parent(s): 0f571f7

Explaination and Radio Button added

Browse files
Files changed (3) hide show
  1. app.py +10 -4
  2. examples.json +4 -0
  3. zx.py +3 -0
app.py CHANGED
@@ -1,17 +1,23 @@
 
1
  from typing import Sequence
2
  import streamlit as st
3
  from hf_model import classifier_zero,load_model
4
  from utils import plot_result
 
5
  classifier=load_model()
 
 
 
6
  if __name__ == '__main__':
7
  st.header("Zero Shot Classification")
8
-
9
 
10
  with st.form(key='my_form'):
11
- text_input = st.text_area(label="Input Text")
12
- labels = st.text_input('Possible topics (separated by `,`)', max_chars=1000)
13
  labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0]))
14
- multi_class = st.checkbox('Allow multiple correct topics', value=True)
 
15
  submit_button = st.form_submit_button(label='Submit')
16
  if submit_button:
17
  if len(labels) == 0:
 
1
+ from os import write
2
  from typing import Sequence
3
  import streamlit as st
4
  from hf_model import classifier_zero,load_model
5
  from utils import plot_result
6
+ import json
7
  classifier=load_model()
8
+ with open("examples.json") as f:
9
+ data=json.load(f)
10
+
11
  if __name__ == '__main__':
12
  st.header("Zero Shot Classification")
13
+ st.write("This app allows you to classify any text into any categories you are interested in.")
14
 
15
  with st.form(key='my_form'):
16
+ text_input = st.text_area("Input Text",data['text'])
17
+ labels = st.text_input('Possible topics (separated by `,`)',data["labels"], max_chars=1000)
18
  labels = list(set([x.strip() for x in labels.strip().split(',') if len(x.strip()) > 0]))
19
+ radio = st.radio("Select Multiclass",('Only one topic can be corect at a time','Multiple topics can be correct at a time'),)
20
+ multi_class= True if radio=="Multiple topics can be correct at a time" else False
21
  submit_button = st.form_submit_button(label='Submit')
22
  if submit_button:
23
  if len(labels) == 0:
examples.json ADDED
@@ -0,0 +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
+ }
zx.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import streamlit as st
2
+ text_input = st.text_area(label="Input Text",placeholder="Hello world!")
3
+ st.write(text_input+"ZZ")