peter2000's picture
Create app.py
f8f1858
raw history blame
No virus
2.08 kB
import gradio as gr
from transformers import pipeline
pipe = pipeline("text-classification", model="jonas/sdg_classifier_osdg")
def predict(text):
preds = pipe(text)[0]
return preds["label"].split('_'), round(preds["score"], 5)
gradio_ui = gr.Interface(
fn=predict,
title="Predict Sustainable Development Goals"
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!.",
inputs=[
gr.inputs.Textbox(lines=5, label="Paste some text here"),
],
outputs=[
gr.outputs.Textbox(label="SDG Label"),
gr.outputs.Textbox(label="Certainty")
],
examples=[
["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."],
["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."]
],
)
gradio_ui.launch(debug=True)