Spaces:
Build error
Build error
Download app.py from pacuare/quickstart: direct link, hf CLI and curl.
- Browser
- Download file 666 Bytes
-
https://huggingface.co/spaces/pacuare/quickstart/resolve/main/app.py
- Command line
-
hf download hf://spaces/pacuare/quickstart/app.py
-
curl -L -o app.py https://huggingface.co/spaces/pacuare/quickstart/resolve/main/app.py
666 Bytes
| import gradio as gr | |
| from client import db | |
| def process(id): | |
| sql = "select injuries, turtle_occurrences from unique_turtles where turtle_id = $1" | |
| params = [id] | |
| if id == '': | |
| sql = "select injuries, turtle_occurrences from unique_turtles" | |
| params = [] | |
| return ( | |
| db.query(sql, params) | |
| .apply( | |
| lambda row: { | |
| **row, | |
| 'n_injuries': len( | |
| [injury for injury in row['injuries'].split(',') if injury.strip() != ''] | |
| ) | |
| }, | |
| axis=1, | |
| result_type='expand' | |
| ) | |
| ) | |
| demo = gr.Interface( | |
| fn=process, | |
| inputs=["text"], | |
| outputs=[gr.ScatterPlot(x='turtle_occurrences', y='n_injuries')] | |
| ) | |
| demo.launch() |