Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
pipe = pipeline("text-classification", model="jonas/sdg_classifier_osdg")
|
|
|
5 |
|
6 |
sdg_dict = {
|
7 |
1:"SDG 1: End poverty in all its forms everywhere",
|
@@ -23,7 +24,8 @@ sdg_dict = {
|
|
23 |
|
24 |
def predict(text):
|
25 |
preds = pipe(text)[0]
|
26 |
-
|
|
|
27 |
|
28 |
gradio_ui = gr.Interface(
|
29 |
fn=predict,
|
@@ -33,6 +35,8 @@ gradio_ui = gr.Interface(
|
|
33 |
gr.inputs.Textbox(lines=5, label="Paste some text here"),
|
34 |
],
|
35 |
outputs=[
|
|
|
|
|
36 |
gr.outputs.Textbox(label="SDG Label"),
|
37 |
gr.outputs.Textbox(label="Certainty")
|
38 |
],
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
pipe = pipeline("text-classification", model="jonas/sdg_classifier_osdg")
|
5 |
+
pipe2 = pipeline("text-classification", model="peter2000/xlm-roberta-base-finetuned-osdg")
|
6 |
|
7 |
sdg_dict = {
|
8 |
1:"SDG 1: End poverty in all its forms everywhere",
|
|
|
24 |
|
25 |
def predict(text):
|
26 |
preds = pipe(text)[0]
|
27 |
+
preds2 = pipe(text)[0]
|
28 |
+
return sdg_dict[int(preds["label"][0])], str(round(preds["score"], 5)*100) + " %", sdg_dict[int(preds2["label"][0])], str(round(preds2["score"], 5)*100) + " %"
|
29 |
|
30 |
gradio_ui = gr.Interface(
|
31 |
fn=predict,
|
|
|
35 |
gr.inputs.Textbox(lines=5, label="Paste some text here"),
|
36 |
],
|
37 |
outputs=[
|
38 |
+
gr.outputs.Textbox(label="SDG Label"),
|
39 |
+
gr.outputs.Textbox(label="Certainty"),
|
40 |
gr.outputs.Textbox(label="SDG Label"),
|
41 |
gr.outputs.Textbox(label="Certainty")
|
42 |
],
|