Spaces:
Build error
Build error
lyangas
commited on
Commit
·
183a63d
1
Parent(s):
73b8367
chacge type of output
Browse files
app.py
CHANGED
@@ -16,17 +16,15 @@ except Exception as e:
|
|
16 |
def classify_code(text):
|
17 |
embed = model._texts2vecs([text])
|
18 |
probs = model.classifier_code.predict_proba(embed)
|
19 |
-
best_n = np.flip(np.argsort(probs, axis=1,)[0
|
20 |
-
preds =
|
21 |
-
#output_text = '\n'.join(preds)
|
22 |
return preds
|
23 |
|
24 |
def classify_group(text):
|
25 |
embed = model._texts2vecs([text])
|
26 |
probs = model.classifier_group.predict_proba(embed)
|
27 |
-
best_n = np.flip(np.argsort(probs, axis=1,)[0
|
28 |
-
preds =
|
29 |
-
# output_text = '\n'.join(preds)
|
30 |
return preds
|
31 |
|
32 |
def classify(text):
|
@@ -40,6 +38,6 @@ iface = gr.Interface(
|
|
40 |
description="",
|
41 |
fn=classify,
|
42 |
inputs=[gr.Textbox(label="Input text", value=default_input_text)],
|
43 |
-
outputs=[gr.
|
44 |
)
|
45 |
iface.launch()
|
|
|
16 |
def classify_code(text):
|
17 |
embed = model._texts2vecs([text])
|
18 |
probs = model.classifier_code.predict_proba(embed)
|
19 |
+
best_n = np.flip(np.argsort(probs, axis=1,)[0])
|
20 |
+
preds = {model.classifier_code.classes_[i]: probs[0][i] for i in best_n}
|
|
|
21 |
return preds
|
22 |
|
23 |
def classify_group(text):
|
24 |
embed = model._texts2vecs([text])
|
25 |
probs = model.classifier_group.predict_proba(embed)
|
26 |
+
best_n = np.flip(np.argsort(probs, axis=1,)[0])
|
27 |
+
preds = {model.classifier_group.classes_[i]: probs[0][i] for i in best_n}
|
|
|
28 |
return preds
|
29 |
|
30 |
def classify(text):
|
|
|
38 |
description="",
|
39 |
fn=classify,
|
40 |
inputs=[gr.Textbox(label="Input text", value=default_input_text)],
|
41 |
+
outputs=[gr.Label(num_top_classes=4, label="Result class"), gr.Label(num_top_classes=4, label="Result group")],
|
42 |
)
|
43 |
iface.launch()
|