Spaces:
Runtime error
Runtime error
harry-stark
commited on
Commit
·
332e4a1
1
Parent(s):
ff6fb57
Explaination and Radio Button added
Browse files- app.py +1 -8
- hf_model.py +0 -1
app.py
CHANGED
@@ -19,16 +19,9 @@ if __name__ == '__main__':
|
|
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:
|
24 |
st.write('Enter some text and at least one possible topic to see predictions.')
|
25 |
top_topics, scores = classifier_zero(classifier,sequence=text_input,labels=labels,multi_class=multi_class)
|
26 |
plot_result(top_topics[::-1][-10:], scores[::-1][-10:])
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
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 |
+
|
23 |
if submit_button:
|
24 |
if len(labels) == 0:
|
25 |
st.write('Enter some text and at least one possible topic to see predictions.')
|
26 |
top_topics, scores = classifier_zero(classifier,sequence=text_input,labels=labels,multi_class=multi_class)
|
27 |
plot_result(top_topics[::-1][-10:], scores[::-1][-10:])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hf_model.py
CHANGED
@@ -9,7 +9,6 @@ def load_model():
|
|
9 |
classifier = pipeline(task='zero-shot-classification', model=model, tokenizer=tokenizer, framework='pt')
|
10 |
return classifier
|
11 |
|
12 |
-
|
13 |
def classifier_zero(classifier,sequence:str,labels:list,multi_class:bool):
|
14 |
outputs=classifier(sequence, labels,multi_label=multi_class)
|
15 |
return outputs['labels'], outputs['scores']
|
|
|
9 |
classifier = pipeline(task='zero-shot-classification', model=model, tokenizer=tokenizer, framework='pt')
|
10 |
return classifier
|
11 |
|
|
|
12 |
def classifier_zero(classifier,sequence:str,labels:list,multi_class:bool):
|
13 |
outputs=classifier(sequence, labels,multi_label=multi_class)
|
14 |
return outputs['labels'], outputs['scores']
|