Spaces:
Sleeping
Sleeping
pjgerrits
commited on
Commit
β’
249a6a3
1
Parent(s):
19d309b
initial streamlit commit
Browse files- .gitattributes +0 -35
- README.md +0 -12
- app.py +78 -0
- requirements.txt +6 -0
- static/Getting Lost Survey.png +0 -0
.gitattributes
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Gettinglost Streamlit
|
3 |
-
emoji: π
|
4 |
-
colorFrom: yellow
|
5 |
-
colorTo: yellow
|
6 |
-
sdk: streamlit
|
7 |
-
sdk_version: 1.35.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import psycopg2
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
st.title("Getting Lost Survey")
|
6 |
+
|
7 |
+
# Database connection
|
8 |
+
@st.cache(allow_output_mutation=True)
|
9 |
+
def connect_to_db():
|
10 |
+
return psycopg2.connect(
|
11 |
+
dbname="glprui_jloddr",
|
12 |
+
user="glprui_jloddr",
|
13 |
+
password="612ef773",
|
14 |
+
host="db.qgiscloud.com",
|
15 |
+
port="5432",
|
16 |
+
sslmode="prefer"
|
17 |
+
)
|
18 |
+
|
19 |
+
# Function to submit data
|
20 |
+
def submit_data(age, gender, transport, multi_transport, time_of_day, day_of_week, description, start_point, lost_point, end_point):
|
21 |
+
conn = connect_to_db()
|
22 |
+
cursor = conn.cursor()
|
23 |
+
|
24 |
+
try:
|
25 |
+
cursor.execute(
|
26 |
+
"""
|
27 |
+
INSERT INTO public.gettinglost_tracking (Age, Gender, Transport, TimeOfDay, DayOfWeek, Description)
|
28 |
+
VALUES (%s, %s, %s, %s, %s, %s) RETURNING ID;
|
29 |
+
""",
|
30 |
+
(age, gender, transport, time_of_day, day_of_week, description)
|
31 |
+
)
|
32 |
+
|
33 |
+
record_id = cursor.fetchone()[0]
|
34 |
+
|
35 |
+
points = {'start': start_point, 'lost': lost_point, 'end': end_point}
|
36 |
+
for pointType, point in points.items():
|
37 |
+
if point:
|
38 |
+
cursor.execute(
|
39 |
+
"""
|
40 |
+
INSERT INTO public.gettinglost_geom (ID, PointType, geom)
|
41 |
+
VALUES (%s, %s, ST_SetSRID(ST_Point(%s, %s), 4326));
|
42 |
+
""",
|
43 |
+
(record_id, pointType, point[1], point[0])
|
44 |
+
)
|
45 |
+
|
46 |
+
conn.commit()
|
47 |
+
st.success("Data recorded successfully!")
|
48 |
+
except Exception as e:
|
49 |
+
conn.rollback()
|
50 |
+
st.error(f"Error: {str(e)}")
|
51 |
+
finally:
|
52 |
+
cursor.close()
|
53 |
+
conn.close()
|
54 |
+
|
55 |
+
# Form inputs
|
56 |
+
age = st.selectbox("Age", ["0-10", "11-20", "21-30", "31-40", "41-50", "51-60", "61-70", "71-80", "81-90", "91-100"])
|
57 |
+
gender = st.radio("Gender", ["M", "F", "O", "PNTS"])
|
58 |
+
transport = st.radio("Mode of Transport", ["Walk", "Car", "Bike", "Train", "Other", "Multi"])
|
59 |
+
|
60 |
+
multi_transport = []
|
61 |
+
if transport == "Multi":
|
62 |
+
multi_transport = st.multiselect("If Multi, Select Modes Used", ["Walk", "Car", "Bike", "Train", "Other"])
|
63 |
+
|
64 |
+
time_of_day = st.selectbox("Time of Day", ["Morning", "Afternoon", "Evening", "Night"])
|
65 |
+
day_of_week = st.selectbox("Day of the Week", ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])
|
66 |
+
description = st.text_area("Why did you get lost?")
|
67 |
+
|
68 |
+
start_point = st.map()
|
69 |
+
lost_point = st.map()
|
70 |
+
end_point = st.map()
|
71 |
+
|
72 |
+
if st.button("Save"):
|
73 |
+
submit_data(age, gender, transport, multi_transport, time_of_day, day_of_week, description, start_point, lost_point, end_point)
|
74 |
+
|
75 |
+
st.markdown("---")
|
76 |
+
st.markdown("For a more detailed survey, click the link or scan the QR code:")
|
77 |
+
st.markdown("[https://arcg.is/1GK5jP0](https://arcg.is/1GK5jP0)")
|
78 |
+
st.image("static/Getting Lost Survey.png", width=200)
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file may be used to create an environment using:
|
2 |
+
# $ conda create --name <env> --file <this file>
|
3 |
+
# platform: osx-64
|
4 |
+
streamlit
|
5 |
+
psycopg2-binary
|
6 |
+
|
static/Getting Lost Survey.png
ADDED
![]() |