Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipe = pipeline("text-classification", model="jonas/sdg_classifier_osdg")
|
5 |
+
|
6 |
+
def predict(text):
|
7 |
+
preds = pipe(text)[0]
|
8 |
+
return preds["label"].split('_'), round(preds["score"], 5)
|
9 |
+
|
10 |
+
gradio_ui = gr.Interface(
|
11 |
+
fn=predict,
|
12 |
+
title="Predict Sustainable Development Goals"
|
13 |
+
description="The Space showcases a Machine Learning model for classifying text according to the first 15 of the 17 Sustainable Development Goals from the United Nations. Note that model is trained on quite short paragraphs (around 100 words) and performs best with similar input sizes. Data comes from the amazing https://osdg.ai/ community!.",
|
14 |
+
inputs=[
|
15 |
+
gr.inputs.Textbox(lines=5, label="Paste some text here"),
|
16 |
+
],
|
17 |
+
outputs=[
|
18 |
+
gr.outputs.Textbox(label="SDG Label"),
|
19 |
+
gr.outputs.Textbox(label="Certainty")
|
20 |
+
],
|
21 |
+
examples=[
|
22 |
+
["To secure sustainable development gains and build resilience in the region, there is an urgent need to undertake climate mitigation and adaptation action. Despite an estimated $391 billion in climate finance flows internationally in 2014, the gap between available climate finance and the financing required to limit global warming to two degrees Celsius and adapt to unavoidable impacts of climate change is growing. The present paper offers an overview of the climate finance landscape with a focus on the Asia-Pacific region, and of finance flows from international climate funds, multilateral development banks and subregional and national climate finance initiatives."],
|
23 |
+
["Making transportation inclusive means also ensuring the affordability of accessible transportation. Accessible ICTs, including mobile applications, government websites, public kiosks and automated teller machines, should be part of accessible urban development plans. Although compact cities can offer enormous potential for persons with disabilities, this potential will not materialize unless accessibility and nondiscrimination are prioritized."]
|
24 |
+
],
|
25 |
+
)
|
26 |
+
|
27 |
+
gradio_ui.launch(debug=True)
|