Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from setfit import SetFitModel | |
| # Download from Hub and run inference | |
| model = SetFitModel.from_pretrained("peter2000/vulnerable-groups-setfit") | |
| group_dict = { | |
| 1: 'Women and girls', | |
| 2: 'Children and youth', | |
| 3: 'Landlocked countries', | |
| 4: 'Outdoor workers', | |
| 5: 'Riverine and flood-prone areas', | |
| 6: 'Small-scale farmers', | |
| 7: 'Men and boys', | |
| 8: 'Small island developing states (SIDS)', | |
| 9: 'Fisherfolk and fishing communities', | |
| 10: 'Children with disabilities', | |
| 11: 'Low-income households', | |
| 12: 'Rural communities', | |
| 13: 'Pregnant women and new mothers', | |
| 14: 'Young adults', | |
| 15: 'Urban slums', | |
| 16: 'Gender non-conforming individuals', | |
| 17: 'Remote communities', | |
| 18: 'Older adults and the elderly', | |
| 19: 'Elderly population', | |
| 20: 'Mountain communities', | |
| 21: 'People with disabilities', | |
| 22: 'Indigenous peoples', | |
| 23: 'Informal settlements and slums', | |
| 24: 'Coastal communities', | |
| 25: 'Informal sector workers', | |
| 26: 'Drought-prone regions', | |
| 27: 'People with pre-existing health conditions', | |
| 28: 'Small-scale farmers and subsistence agriculture', | |
| 29: 'Migrants and displaced populations', | |
| 30: 'no vulnerable group mentioned'} | |
| def predict(text): | |
| preds = model([text])[0].item() | |
| return group_dict[preds] | |
| gradio_ui = gr.Interface( | |
| fn=predict, | |
| title="Predict reference to vulnerable groups", | |
| description="This Space showcases.", | |
| inputs=[ | |
| gr.inputs.Textbox(lines=5, label="Paste some text here"), | |
| ], | |
| outputs=[ | |
| gr.outputs.Textbox(label="Vulnerable group"), | |
| ], | |
| examples=[ | |
| ["To promote gender equality and empower men and boys as agents of change in climate adaptation efforts, we aim to engage 300,000 men and boys in gender-responsive climate change adaptation initiatives by 2030, focusing on capacity building, leadership development, and community engagement."], | |
| ["To preserve the traditional knowledge and resources of indigenous peoples in the face of climate change, we commit to protecting and restoring 2 million hectares of indigenous peoples' traditional lands by 2030, focusing on sustainable land management practices, ecosystem restoration, and the conservation of biodiversity"], | |
| #["Through the Paris Agreement, Parties to the United Nations Framework Convention on Climate Change (UNFCCC) have agreed to limit the increase in the global average temperature to well below 2°C above pre-industrial levels, and pursue efforts to limit the temperature increase to 1.5°C above pre-industrial levels."] | |
| ], | |
| ) | |
| gradio_ui.launch(debug=True) |