abhishek thakur commited on
Commit
227de0b
Β·
1 Parent(s): 94ce484
Dockerfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.8.9
2
+
3
+ RUN pip install pip==22.3.1
4
+
5
+ WORKDIR /app
6
+ RUN mkdir -p /app/.cache
7
+ ENV HF_HOME="/app/.cache"
8
+ RUN chown -R 1000:1000 /app
9
+ USER 1000
10
+ ENV HOME=/app
11
+
12
+ RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
13
+ && sh Miniconda3-latest-Linux-x86_64.sh -b -p /app/miniconda \
14
+ && rm -f Miniconda3-latest-Linux-x86_64.sh
15
+ ENV PATH /app/miniconda/bin:$PATH
16
+
17
+ RUN conda create -p /app/env -y python=3.8
18
+
19
+ SHELL ["conda", "run","--no-capture-output", "-p","/app/env", "/bin/bash", "-c"]
20
+
21
+ COPY --chown=1000:1000 requirements.txt /app/requirements.txt
22
+ RUN pip install -r requirements.txt
23
+
24
+ COPY --chown=1000:1000 *.py /app/
25
+ COPY --chown=1000:1000 pages/ /app/pages/
26
+
27
+ CMD streamlit run Overview.py \
28
+ --server.headless true \
29
+ --server.enableCORS false \
30
+ --server.enableXsrfProtection false \
31
+ --server.fileWatcherType none
Overview.py CHANGED
@@ -14,3 +14,7 @@ st.markdown(
14
  {config.competition_info.competition_description}
15
  """
16
  )
 
 
 
 
 
14
  {config.competition_info.competition_description}
15
  """
16
  )
17
+
18
+ st.markdown("## Dataset")
19
+ # st.sidebar.header("Dataset")
20
+ st.write(f"""{config.competition_info.dataset_description}""")
README.md CHANGED
@@ -1,12 +1,9 @@
1
  ---
2
- title: Test Competition
3
  emoji: 🏒
4
  colorFrom: indigo
5
  colorTo: gray
6
- sdk: streamlit
7
- sdk_version: 1.10.0
8
- app_file: Overview.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Shoes vs Boots vs Sandals
3
  emoji: 🏒
4
  colorFrom: indigo
5
  colorTo: gray
6
+ sdk: docker
 
 
7
  pinned: false
8
+ app_port: 8501
9
  ---
 
 
pages/{2_πŸ”₯_New Submission.py β†’ 1_πŸ”₯_Submissions.py} RENAMED
@@ -1,7 +1,10 @@
1
  import uuid
 
2
 
 
3
  import streamlit as st
4
  from huggingface_hub import HfApi
 
5
 
6
  import config
7
  import utils
@@ -16,16 +19,35 @@ The final rankings will be based on the private split performance.
16
  SUBMISSION_ERROR = """Submission is not in a proper format.
17
  Please check evaluation instructions for more details."""
18
 
 
 
19
 
20
- def app():
21
- st.set_page_config(page_title="New Submissions", page_icon="πŸ€—")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  st.write("## New Submission")
23
  st.markdown(SUBMISSION_TEXT)
24
  uploaded_file = st.file_uploader("Choose a file")
25
- # user token
26
- user_token = st.text_input("Enter your Hugging Face token", value="", type="password")
27
- user_token = user_token.strip()
28
- # add submit button
29
  submit_button = st.button("Submit")
30
  if uploaded_file is not None and user_token != "" and submit_button:
31
  # verify token
@@ -83,5 +105,39 @@ def app():
83
  )
84
 
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  if __name__ == "__main__":
87
  app()
 
1
  import uuid
2
+ from datetime import datetime
3
 
4
+ import pandas as pd
5
  import streamlit as st
6
  from huggingface_hub import HfApi
7
+ from huggingface_hub.utils._errors import EntryNotFoundError
8
 
9
  import config
10
  import utils
 
19
  SUBMISSION_ERROR = """Submission is not in a proper format.
20
  Please check evaluation instructions for more details."""
21
 
22
+ SUBMISSION_LIMIT_TEXT = f"""You can select upto {config.competition_info.selection_limit}
23
+ submissions for private leaderboard."""
24
 
25
+
26
+ def get_subs(user_info, private=False):
27
+ # get user submissions
28
+ user_id = user_info["id"]
29
+ try:
30
+ user_submissions = utils.fetch_submissions(user_id)
31
+ except EntryNotFoundError:
32
+ st.error("No submissions found")
33
+ return
34
+ submissions_df = pd.DataFrame(user_submissions)
35
+ if not private:
36
+ submissions_df = submissions_df.drop(columns=["private_score"])
37
+ submissions_df = submissions_df[
38
+ ["date", "submission_id", "public_score", "submission_comment", "selected", "status"]
39
+ ]
40
+ else:
41
+ submissions_df = submissions_df[
42
+ ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
43
+ ]
44
+ st.write(submissions_df)
45
+
46
+
47
+ def new_submission(user_token):
48
  st.write("## New Submission")
49
  st.markdown(SUBMISSION_TEXT)
50
  uploaded_file = st.file_uploader("Choose a file")
 
 
 
 
51
  submit_button = st.button("Submit")
52
  if uploaded_file is not None and user_token != "" and submit_button:
53
  # verify token
 
105
  )
106
 
107
 
108
+ def my_submissions(user_token):
109
+ st.write("## Your Submissions")
110
+ st.markdown(SUBMISSION_LIMIT_TEXT)
111
+ if user_token != "":
112
+ user_info = utils.user_authentication(token=user_token)
113
+ if "error" in user_info:
114
+ st.error("Invalid token")
115
+ return
116
+
117
+ if user_info["emailVerified"] is False:
118
+ st.error("Please verify your email on Hugging Face Hub")
119
+ return
120
+
121
+ current_date_time = datetime.now()
122
+ private = False
123
+ if current_date_time >= config.competition_info.end_date:
124
+ private = True
125
+ get_subs(user_info, private=private)
126
+
127
+
128
+ def app():
129
+ st.set_page_config(page_title="Submissions", page_icon="πŸ€—")
130
+ st.markdown("## Submissions")
131
+ user_token = st.text_input("Enter your Hugging Face token", value="", type="password")
132
+ user_token = user_token.strip()
133
+ new_sub, my_sub = st.tabs(["New Submission", "My Submissions"])
134
+
135
+ with new_sub:
136
+ new_submission(user_token)
137
+
138
+ with my_sub:
139
+ my_submissions(user_token)
140
+
141
+
142
  if __name__ == "__main__":
143
  app()
pages/1_πŸ€—_Dataset.py DELETED
@@ -1,14 +0,0 @@
1
- import streamlit as st
2
- import config
3
-
4
-
5
- def app():
6
- st.set_page_config(page_title="Dataset", page_icon="πŸ“ˆ")
7
-
8
- st.markdown("# Dataset")
9
- # st.sidebar.header("Dataset")
10
- st.write(f"""{config.competition_info.dataset_description}""")
11
-
12
-
13
- if __name__ == "__main__":
14
- app()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/2_πŸ“_Leaderboard.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ import streamlit as st
4
+
5
+ import config
6
+ import utils
7
+
8
+
9
+ def app():
10
+ st.set_page_config(page_title="Leaderboard", page_icon="πŸ€—")
11
+ st.markdown("## Leaderboard")
12
+ public_lb, private_lb = st.tabs(["Public", "Private"])
13
+ current_date_time = datetime.now()
14
+
15
+ with public_lb:
16
+ lb = utils.fetch_leaderboard(private=False)
17
+ st.table(lb)
18
+
19
+ with private_lb:
20
+ if current_date_time >= config.competition_info.end_date:
21
+ lb = utils.fetch_leaderboard(private=True)
22
+ st.table(lb)
23
+ else:
24
+ st.error("Private Leaderboard will be available after the competition ends")
25
+
26
+
27
+ if __name__ == "__main__":
28
+ app()
pages/3_⭐️_Submission History.py DELETED
@@ -1,62 +0,0 @@
1
- from datetime import datetime
2
-
3
- import pandas as pd
4
- import streamlit as st
5
- from huggingface_hub.utils._errors import EntryNotFoundError
6
-
7
- import config
8
- import utils
9
-
10
- SUBMISSION_TEXT = f"""You can select upto {config.competition_info.selection_limit}
11
- submissions for private leaderboard."""
12
-
13
-
14
- def get_subs(user_info, private=False):
15
- # get user submissions
16
- user_id = user_info["id"]
17
- try:
18
- user_submissions = utils.fetch_submissions(user_id)
19
- except EntryNotFoundError:
20
- st.error("No submissions found")
21
- return
22
- submissions_df = pd.DataFrame(user_submissions)
23
- if not private:
24
- submissions_df = submissions_df.drop(columns=["private_score"])
25
- submissions_df = submissions_df[
26
- ["date", "submission_id", "public_score", "submission_comment", "selected", "status"]
27
- ]
28
- else:
29
- submissions_df = submissions_df[
30
- ["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
31
- ]
32
- st.write(submissions_df)
33
-
34
-
35
- def app():
36
- st.set_page_config(page_title="Submission History", page_icon="πŸ€—")
37
- st.write("## Your Submissions")
38
- st.markdown(SUBMISSION_TEXT)
39
- # user token
40
- user_token = st.text_input("Enter your Hugging Face token", value="", type="password")
41
- user_token = user_token.strip()
42
- # add submit button
43
- submit_button = st.button("Submit")
44
- if user_token != "" and submit_button:
45
- user_info = utils.user_authentication(token=user_token)
46
- if "error" in user_info:
47
- st.error("Invalid token")
48
- return
49
-
50
- if user_info["emailVerified"] is False:
51
- st.error("Please verify your email on Hugging Face Hub")
52
- return
53
-
54
- current_date_time = datetime.now()
55
- private = False
56
- if current_date_time >= config.competition_info.end_date:
57
- private = True
58
- get_subs(user_info, private=private)
59
-
60
-
61
- if __name__ == "__main__":
62
- app()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/4_πŸ“_Public Leaderboard.py DELETED
@@ -1,14 +0,0 @@
1
- import streamlit as st
2
-
3
- import utils
4
-
5
-
6
- def app():
7
- st.set_page_config(page_title="Public Leaderboard", page_icon="πŸ€—")
8
- st.markdown("## Public Leaderboard")
9
- lb = utils.fetch_leaderboard(private=False)
10
- st.table(lb)
11
-
12
-
13
- if __name__ == "__main__":
14
- app()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/5_πŸ“_Private Leaderboard.py DELETED
@@ -1,23 +0,0 @@
1
- from datetime import datetime
2
-
3
- import streamlit as st
4
-
5
- import config
6
- import utils
7
-
8
-
9
- def app():
10
- st.set_page_config(page_title="Private Leaderboard", page_icon="πŸ€—")
11
- st.markdown("## Private Leaderboard")
12
- current_date_time = datetime.now()
13
-
14
- if current_date_time >= config.competition_info.end_date:
15
- st.header("Private Leaderboard")
16
- lb = utils.fetch_leaderboard(private=True)
17
- st.table(lb)
18
- else:
19
- st.error("Private Leaderboard will be available after the competition ends")
20
-
21
-
22
- if __name__ == "__main__":
23
- app()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
utils.py CHANGED
@@ -186,7 +186,7 @@ def check_user_submission_limit(user_info):
186
  for sub in user_submission_info["submissions"]:
187
  if sub["date"] == todays_date:
188
  todays_submissions += 1
189
- if todays_submissions >= config.SUBMISSION_LIMIT:
190
  return False
191
  return True
192
 
 
186
  for sub in user_submission_info["submissions"]:
187
  if sub["date"] == todays_date:
188
  todays_submissions += 1
189
+ if todays_submissions >= config.competition_info.submission_limit:
190
  return False
191
  return True
192