Spaces:
Sleeping
Sleeping
File size: 2,003 Bytes
74e80c5 49c0458 d43a9e4 bbf4029 72bac2a bbf4029 6567232 38cceb0 6567232 49c0458 72bac2a d43a9e4 fdf8211 1a66f00 41fbada 1a66f00 fdf8211 c921aca d43a9e4 c921aca d43a9e4 c921aca 6567232 c921aca 6567232 c921aca 6567232 c921aca d43a9e4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
import os
import streamlit as st
import pandas as pd
import numpy as np
import huggingface_hub as hfh
voters = [
"osman",
"eren",
"robin",
"mira",
"bilal",
"volunteer-1",
"volunteer-2",
"volunteer-3",
"volunteer-4",
"volunteer-5",
]
# login page
with st.form("login"):
username = st.selectbox("Select voter", voters)
password = st.text_input("Password (get password from [email protected])", type="password")
submitted = st.form_submit_button("Login")
def get_list_of_images():
# fs = hfh.HfFileSystem(token=os.environ.get("hf_token"))
# return fs.ls("datasets/aifred-smart-life-coach/capstone-images", detail=False, refresh=True)
api = hfh.HfApi()
files = api.list_repo_tree(repo_id="aifred-smart-life-coach/capstone-images", repo_type="dataset", recursive=True)
files = list(files)
print(type(files[1]))
return files
def get_one_from_queue(voter: str):
# get an image for the voter or return False if no image is left
return None
st.write(get_list_of_images())
if submitted:
if not password == os.environ.get("app_password"):
st.error("The password you entered is incorrect")
st.stop()
else:
st.success("Welcome, " + username)
st.write("You are now logged in")
with st.form("images"):
queue = get_one_from_queue(username)
if not queue:
st.write("You have voted for all the images")
st.stop()
st.image(queue["image"])
healthiness = st.slider("How healthy is this picture?", 0, 100, 50)
fat_level = st.slider("How fat is this picture?", 0, 100, 50)
muscle_level = st.slider("How muscular is this picture?", 0, 100, 50)
# Every form must have a submit button.
submitted = st.form_submit_button("Submit")
if submitted:
st.write("slideers", healthiness, fat_level, muscle_level)
# push the data to the database
st.write("Outside the form")
|