Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,6 @@ import gradio as gr
|
|
3 |
import pandas as pd
|
4 |
|
5 |
|
6 |
-
|
7 |
-
def coding_v1(model, text, codetext):
|
8 |
-
classifier = pipeline("zero-shot-classification", model=model)
|
9 |
-
codelist = codetext.split(';')
|
10 |
-
output = classifier(text, codelist, multi_label=True)
|
11 |
-
return output
|
12 |
-
|
13 |
def coding(model, text, codetext):
|
14 |
classifier = pipeline("zero-shot-classification", model=model)
|
15 |
codelist = codetext.split(';')
|
@@ -19,7 +12,7 @@ def coding(model, text, codetext):
|
|
19 |
keys = output['labels']
|
20 |
values = output['scores']
|
21 |
my_dict = {k: v for k, v in zip(keys, values)}
|
22 |
-
return my_dict
|
23 |
|
24 |
def upload_code_list(file):
|
25 |
df = pd.read_excel(file.name, sheet_name='code')
|
@@ -75,10 +68,10 @@ with demo:
|
|
75 |
variant='primary'
|
76 |
)
|
77 |
with gr.Column():
|
78 |
-
#result_text = gr.JSON()
|
79 |
result_label = gr.Label(show_label=False)
|
|
|
80 |
|
81 |
-
run_btn.click(coding, [select_model, comment_text, codelist_text], result_label, scroll_to_output=True)
|
82 |
|
83 |
if __name__ == "__main__":
|
84 |
demo.launch()
|
|
|
3 |
import pandas as pd
|
4 |
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def coding(model, text, codetext):
|
7 |
classifier = pipeline("zero-shot-classification", model=model)
|
8 |
codelist = codetext.split(';')
|
|
|
12 |
keys = output['labels']
|
13 |
values = output['scores']
|
14 |
my_dict = {k: v for k, v in zip(keys, values)}
|
15 |
+
return [my_dict, oytput]
|
16 |
|
17 |
def upload_code_list(file):
|
18 |
df = pd.read_excel(file.name, sheet_name='code')
|
|
|
68 |
variant='primary'
|
69 |
)
|
70 |
with gr.Column():
|
|
|
71 |
result_label = gr.Label(show_label=False)
|
72 |
+
result_text = gr.JSON()
|
73 |
|
74 |
+
run_btn.click(coding, [select_model, comment_text, codelist_text], [result_label, result_label], scroll_to_output=True)
|
75 |
|
76 |
if __name__ == "__main__":
|
77 |
demo.launch()
|