Spaces:
Build error
Build error
Commit ·
dabea62
1
Parent(s): 7d3ed7e
Initial commit
Browse files- .env +1 -0
- .gitignore +2 -0
- app.py +30 -0
- client.py +4 -0
- requirements.txt +3 -0
.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
PACUARE_API_KEY=a13f24adf15a47e0f4b99406cacf4d95
|
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.venv/
|
| 2 |
+
__pycache__/
|
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from client import db
|
| 3 |
+
|
| 4 |
+
def process(id):
|
| 5 |
+
sql = "select injuries, turtle_occurrences from unique_turtles where turtle_id = $1"
|
| 6 |
+
params = [id]
|
| 7 |
+
if id == '':
|
| 8 |
+
sql = "select injuries, turtle_occurrences from unique_turtles"
|
| 9 |
+
params = []
|
| 10 |
+
return (
|
| 11 |
+
db.query(sql, params)
|
| 12 |
+
.apply(
|
| 13 |
+
lambda row: {
|
| 14 |
+
**row,
|
| 15 |
+
'n_injuries': len(
|
| 16 |
+
[injury for injury in row['injuries'].split(',') if injury.strip() != '']
|
| 17 |
+
)
|
| 18 |
+
},
|
| 19 |
+
axis=1,
|
| 20 |
+
result_type='expand'
|
| 21 |
+
)
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=process,
|
| 26 |
+
inputs=["text"],
|
| 27 |
+
outputs=[gr.ScatterPlot(x='turtle_occurrences', y='n_injuries')]
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
demo.launch()
|
client.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from pacuare import Client
|
| 3 |
+
|
| 4 |
+
db = Client(os.getenv("PACUARE_API_KEY", ''))
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
pandas
|
| 3 |
+
pacuare
|