Spaces:
Running
Running
update
Browse files
app.py
CHANGED
@@ -3,6 +3,9 @@ import streamlit as st
|
|
3 |
import pandas as pd
|
4 |
import numpy as np
|
5 |
import huggingface_hub as hfh
|
|
|
|
|
|
|
6 |
|
7 |
voters = [
|
8 |
"osman",
|
@@ -37,15 +40,31 @@ def get_one_from_queue(voter: str):
|
|
37 |
# aifred-smart-life-coach/labels labels dataset
|
38 |
# labels dataset multiple csv files named as [voter name].csv
|
39 |
# each csv file has the image image path vote date, votes
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
if file.path == f"{voter}.csv":
|
44 |
-
df = pd.read_csv(api.download_file(file.path))
|
45 |
-
print(df)
|
46 |
|
47 |
-
return None
|
48 |
|
|
|
49 |
|
50 |
if submitted:
|
51 |
if not password == os.environ.get("app_password"):
|
@@ -60,7 +79,13 @@ if submitted:
|
|
60 |
if not queue:
|
61 |
st.write("You have voted for all the images")
|
62 |
st.stop()
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
healthiness = st.slider("How healthy is this picture?", 0, 100, 50)
|
65 |
fat_level = st.slider("How fat is this picture?", 0, 100, 50)
|
66 |
muscle_level = st.slider("How muscular is this picture?", 0, 100, 50)
|
|
|
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 |
|
10 |
voters = [
|
11 |
"osman",
|
|
|
40 |
# aifred-smart-life-coach/labels labels dataset
|
41 |
# labels dataset multiple csv files named as [voter name].csv
|
42 |
# each csv file has the image image path vote date, votes
|
43 |
+
url = f"https://huggingface.co/datasets/aifred-smart-life-coach/labels/raw/main/{voter}.csv"
|
44 |
+
|
45 |
+
# fetch file and save it to the labels folder
|
46 |
+
file_path = f"labels/{voter}.csv"
|
47 |
+
req = requests.get(url)
|
48 |
+
with open(file_path, "wb") as file:
|
49 |
+
file.write(req.content)
|
50 |
+
|
51 |
+
df = pd.read_csv(file_path)
|
52 |
+
print(df)
|
53 |
+
num_past_votes = df.shape[0]
|
54 |
+
print("num_past_votes", num_past_votes)
|
55 |
+
|
56 |
+
list_of_images = get_list_of_images()
|
57 |
+
print("list_of_images", len(list_of_images))
|
58 |
+
|
59 |
+
# get the list of images that are not present in the csv file
|
60 |
+
images_not_voted = list(set(list_of_images) - set(df["image_path"].tolist()))
|
61 |
+
print("images_not_voted", len(images_not_voted))
|
62 |
+
|
63 |
|
64 |
+
return {"image": images_not_voted[0]} if images_not_voted else False
|
|
|
|
|
|
|
65 |
|
|
|
66 |
|
67 |
+
print(get_one_from_queue("osman"))
|
68 |
|
69 |
if submitted:
|
70 |
if not password == os.environ.get("app_password"):
|
|
|
79 |
if not queue:
|
80 |
st.write("You have voted for all the images")
|
81 |
st.stop()
|
82 |
+
# https://huggingface.co/datasets/aifred-smart-life-coach/capstone-images/resolve/main/kaggle-human-segmentation-dataset/Women%20I/img/woman_image_200.jpg
|
83 |
+
st.image(f"https://huggingface.co/datasets/aifred-smart-life-coach/capstone-images/resolve/main/{queue['image']}", width=300)
|
84 |
+
gender = st.select([
|
85 |
+
"Male",
|
86 |
+
"Female",
|
87 |
+
"Non-defining",
|
88 |
+
])
|
89 |
healthiness = st.slider("How healthy is this picture?", 0, 100, 50)
|
90 |
fat_level = st.slider("How fat is this picture?", 0, 100, 50)
|
91 |
muscle_level = st.slider("How muscular is this picture?", 0, 100, 50)
|