Spaces:
Sleeping
Sleeping
add this
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import os
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
-
import numpy as np
|
5 |
import huggingface_hub as hfh
|
6 |
import requests
|
|
|
7 |
|
8 |
os.makedirs("labels", exist_ok=True)
|
9 |
|
@@ -60,6 +60,7 @@ def get_one_from_queue(voter: str):
|
|
60 |
def update_vote(
|
61 |
voter: str,
|
62 |
image: str,
|
|
|
63 |
healthiness: int,
|
64 |
fat_level: int,
|
65 |
muscle_level: int,
|
@@ -75,13 +76,19 @@ def update_vote(
|
|
75 |
df = pd.read_csv(file_path)
|
76 |
print(df)
|
77 |
|
78 |
-
new_row =
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
df.to_csv(file_path, index=False)
|
86 |
|
87 |
# push the file to the dataset
|
@@ -111,7 +118,12 @@ if submitted or st.session_state['loggedin'] == 'true':
|
|
111 |
st.write("You have voted for all the images")
|
112 |
st.stop()
|
113 |
|
114 |
-
path = hfh.hf_hub_download(
|
|
|
|
|
|
|
|
|
|
|
115 |
st.image(path, width=300)
|
116 |
gender = st.selectbox("Gender", [
|
117 |
"Male",
|
@@ -125,7 +137,14 @@ if submitted or st.session_state['loggedin'] == 'true':
|
|
125 |
submitted_second = st.form_submit_button("Submit")
|
126 |
|
127 |
if submitted_second:
|
128 |
-
update_vote(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
st.write("Vote submitted")
|
130 |
# push the data to the database
|
131 |
|
|
|
1 |
import os
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
|
|
4 |
import huggingface_hub as hfh
|
5 |
import requests
|
6 |
+
import time
|
7 |
|
8 |
os.makedirs("labels", exist_ok=True)
|
9 |
|
|
|
60 |
def update_vote(
|
61 |
voter: str,
|
62 |
image: str,
|
63 |
+
gender: str,
|
64 |
healthiness: int,
|
65 |
fat_level: int,
|
66 |
muscle_level: int,
|
|
|
76 |
df = pd.read_csv(file_path)
|
77 |
print(df)
|
78 |
|
79 |
+
new_row = pd.DataFrame(
|
80 |
+
{
|
81 |
+
"image_path": [image],
|
82 |
+
"gender": [ gender ],
|
83 |
+
"healthiness": [healthiness],
|
84 |
+
"fat_level": [fat_level],
|
85 |
+
"muscle_level": [muscle_level],
|
86 |
+
"vote_date": [int(time.time())],
|
87 |
+
"voter_name": [voter],
|
88 |
+
}
|
89 |
+
)
|
90 |
+
|
91 |
+
df = df.concat([df, new_row])
|
92 |
df.to_csv(file_path, index=False)
|
93 |
|
94 |
# push the file to the dataset
|
|
|
118 |
st.write("You have voted for all the images")
|
119 |
st.stop()
|
120 |
|
121 |
+
path = hfh.hf_hub_download(
|
122 |
+
repo_id="aifred-smart-life-coach/capstone-images",
|
123 |
+
repo_type="dataset",
|
124 |
+
filename=image_path,
|
125 |
+
token=os.environ.get("hf_token")
|
126 |
+
)
|
127 |
st.image(path, width=300)
|
128 |
gender = st.selectbox("Gender", [
|
129 |
"Male",
|
|
|
137 |
submitted_second = st.form_submit_button("Submit")
|
138 |
|
139 |
if submitted_second:
|
140 |
+
update_vote(
|
141 |
+
voter=username,
|
142 |
+
image=image_path,
|
143 |
+
gender=gender,
|
144 |
+
healthiness=healthiness,
|
145 |
+
fat_level=fat_level,
|
146 |
+
muscle_level=muscle_level
|
147 |
+
)
|
148 |
st.write("Vote submitted")
|
149 |
# push the data to the database
|
150 |
|