Abhishek Thakur
commited on
Commit
Β·
f3fe9b4
1
Parent(s):
8ec4d2d
public & private lb
Browse files- Makefile +10 -0
- Overview.py +4 -2
- config.py +6 -1
- pages/1_π€_Dataset.py +0 -2
- pages/2_π_Leaderboard.py +1 -1
- pages/3_π₯_New Submission.py +5 -5
- pages/4_βοΈ_Submission History.py +39 -10
- utils.py +10 -4
Makefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.PHONY: quality style
|
| 2 |
+
|
| 3 |
+
quality:
|
| 4 |
+
python -m black --check --line-length 119 --target-version py38 .
|
| 5 |
+
python -m isort --check-only .
|
| 6 |
+
python -m flake8 --max-line-length 119
|
| 7 |
+
|
| 8 |
+
style:
|
| 9 |
+
python -m black --line-length 119 --target-version py38 .
|
| 10 |
+
python -m isort .
|
Overview.py
CHANGED
|
@@ -10,7 +10,8 @@ st.write("# Welcome to Cats vs Dogs! π")
|
|
| 10 |
st.markdown(
|
| 11 |
"""
|
| 12 |
In this competition, you will be creating an image classifier that can distinguish between cats and dogs.
|
| 13 |
-
You can use any model you want, but we recommend using a pretrained model from the
|
|
|
|
| 14 |
|
| 15 |
Rules:
|
| 16 |
- You can make upto 5 submissions per day.
|
|
@@ -19,7 +20,8 @@ st.markdown(
|
|
| 19 |
- Your final score will be based on your private split performance.
|
| 20 |
- The final rankings will be based on the private split performance.
|
| 21 |
- No cheating! You can only use the test data for inference. You cannot use it to train your model.
|
| 22 |
-
- No private sharing of code or data. You can discuss the competition on the forums, but please do not share any
|
|
|
|
| 23 |
- Have fun! π€
|
| 24 |
|
| 25 |
For detailed rules, please check the [rules page](https://huggingface.co/competitions/transformers-cats-vs-dogs).
|
|
|
|
| 10 |
st.markdown(
|
| 11 |
"""
|
| 12 |
In this competition, you will be creating an image classifier that can distinguish between cats and dogs.
|
| 13 |
+
You can use any model you want, but we recommend using a pretrained model from the
|
| 14 |
+
[π€ Hub](https://huggingface.co/models).
|
| 15 |
|
| 16 |
Rules:
|
| 17 |
- You can make upto 5 submissions per day.
|
|
|
|
| 20 |
- Your final score will be based on your private split performance.
|
| 21 |
- The final rankings will be based on the private split performance.
|
| 22 |
- No cheating! You can only use the test data for inference. You cannot use it to train your model.
|
| 23 |
+
- No private sharing of code or data. You can discuss the competition on the forums, but please do not share any
|
| 24 |
+
code or data.
|
| 25 |
- Have fun! π€
|
| 26 |
|
| 27 |
For detailed rules, please check the [rules page](https://huggingface.co/competitions/transformers-cats-vs-dogs).
|
config.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import os
|
| 2 |
-
from
|
| 3 |
from pathlib import Path
|
| 4 |
|
|
|
|
|
|
|
| 5 |
if Path(".env").is_file():
|
| 6 |
load_dotenv(".env")
|
| 7 |
|
|
@@ -14,3 +16,6 @@ AUTOTRAIN_TOKEN = os.getenv("AUTOTRAIN_TOKEN")
|
|
| 14 |
HF_ACCESS_TOKEN = os.getenv("HF_ACCESS_TOKEN")
|
| 15 |
AUTOTRAIN_BACKEND_API = os.getenv("AUTOTRAIN_BACKEND_API")
|
| 16 |
SUBMISSION_LIMIT = int(os.getenv("SUBMISSION_LIMIT"))
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
from datetime import datetime
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
|
| 7 |
if Path(".env").is_file():
|
| 8 |
load_dotenv(".env")
|
| 9 |
|
|
|
|
| 16 |
HF_ACCESS_TOKEN = os.getenv("HF_ACCESS_TOKEN")
|
| 17 |
AUTOTRAIN_BACKEND_API = os.getenv("AUTOTRAIN_BACKEND_API")
|
| 18 |
SUBMISSION_LIMIT = int(os.getenv("SUBMISSION_LIMIT"))
|
| 19 |
+
SELECTION_LIMIT = int(os.getenv("SELECTION_LIMIT"))
|
| 20 |
+
END_DATE = os.getenv("END_DATE")
|
| 21 |
+
END_DATE = datetime.strptime(END_DATE, "%Y-%m-%d")
|
pages/1_π€_Dataset.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import time
|
| 3 |
-
import numpy as np
|
| 4 |
|
| 5 |
|
| 6 |
def app():
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
def app():
|
pages/2_π_Leaderboard.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
def fetch_leaderboard():
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
|
| 4 |
|
| 5 |
def fetch_leaderboard():
|
pages/3_π₯_New Submission.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from huggingface_hub import HfApi, CommitOperationAdd
|
| 3 |
import uuid
|
| 4 |
-
|
| 5 |
-
import
|
| 6 |
-
import
|
|
|
|
| 7 |
import config
|
|
|
|
| 8 |
|
| 9 |
SUBMISSION_TEXT = """You can make upto 5 submissions per day.
|
| 10 |
The test data has been divided into public and private splits.
|
|
|
|
|
|
|
|
|
|
| 1 |
import uuid
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
from huggingface_hub import HfApi
|
| 5 |
+
|
| 6 |
import config
|
| 7 |
+
import utils
|
| 8 |
|
| 9 |
SUBMISSION_TEXT = """You can make upto 5 submissions per day.
|
| 10 |
The test data has been divided into public and private splits.
|
pages/4_βοΈ_Submission History.py
CHANGED
|
@@ -1,15 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import uuid
|
| 4 |
-
import os
|
| 5 |
import pandas as pd
|
| 6 |
-
import
|
|
|
|
| 7 |
import config
|
|
|
|
| 8 |
|
| 9 |
SUBMISSION_TEXT = """You can select upto 2 submissions for private leaderboard.
|
| 10 |
"""
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def app():
|
| 14 |
st.set_page_config(page_title="Submission History", page_icon="π€")
|
| 15 |
st.write("## Your Submissions")
|
|
@@ -27,11 +44,23 @@ def app():
|
|
| 27 |
st.error("Please verify your email on Hugging Face Hub")
|
| 28 |
return
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
from datetime import datetime
|
| 2 |
+
|
|
|
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
+
import streamlit as st
|
| 5 |
+
|
| 6 |
import config
|
| 7 |
+
import utils
|
| 8 |
|
| 9 |
SUBMISSION_TEXT = """You can select upto 2 submissions for private leaderboard.
|
| 10 |
"""
|
| 11 |
|
| 12 |
|
| 13 |
+
def get_subs(user_info, private=False):
|
| 14 |
+
# get user submissions
|
| 15 |
+
user_id = user_info["id"]
|
| 16 |
+
user_submissions = utils.fetch_submissions(user_id)
|
| 17 |
+
submissions_df = pd.DataFrame(user_submissions)
|
| 18 |
+
if not private:
|
| 19 |
+
submissions_df = submissions_df.drop(columns=["private_score"])
|
| 20 |
+
submissions_df = submissions_df[
|
| 21 |
+
["date", "submission_id", "public_score", "submission_comment", "selected", "status"]
|
| 22 |
+
]
|
| 23 |
+
else:
|
| 24 |
+
submissions_df = submissions_df[
|
| 25 |
+
["date", "submission_id", "public_score", "private_score", "submission_comment", "selected", "status"]
|
| 26 |
+
]
|
| 27 |
+
return submissions_df
|
| 28 |
+
|
| 29 |
+
|
| 30 |
def app():
|
| 31 |
st.set_page_config(page_title="Submission History", page_icon="π€")
|
| 32 |
st.write("## Your Submissions")
|
|
|
|
| 44 |
st.error("Please verify your email on Hugging Face Hub")
|
| 45 |
return
|
| 46 |
|
| 47 |
+
public_lb, private_lb = st.tabs(["Public", "Private"])
|
| 48 |
+
current_date_time = datetime.now()
|
| 49 |
+
print(current_date_time)
|
| 50 |
+
print(config.END_DATE)
|
| 51 |
+
print(current_date_time >= config.END_DATE)
|
| 52 |
+
with public_lb:
|
| 53 |
+
st.header("Public Leaderboard")
|
| 54 |
+
submission_df = get_subs(user_info, private=False)
|
| 55 |
+
st.write(submission_df)
|
| 56 |
+
|
| 57 |
+
with private_lb:
|
| 58 |
+
if current_date_time >= config.END_DATE:
|
| 59 |
+
st.header("Private Leaderboard")
|
| 60 |
+
submission_df = get_subs(user_info, private=True)
|
| 61 |
+
st.write(submission_df)
|
| 62 |
+
else:
|
| 63 |
+
st.error("Private Leaderboard will be available after the competition ends")
|
| 64 |
|
| 65 |
|
| 66 |
if __name__ == "__main__":
|
utils.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import time
|
|
|
|
| 2 |
import requests
|
| 3 |
-
import config
|
| 4 |
from huggingface_hub import HfApi, hf_hub_download
|
| 5 |
-
import json
|
| 6 |
-
import datetime
|
| 7 |
-
import io
|
| 8 |
from huggingface_hub.utils._errors import EntryNotFoundError
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def get_auth_headers(token: str, prefix: str = "Bearer"):
|
| 12 |
return {"Authorization": f"{prefix} {token}"}
|
|
@@ -199,12 +201,16 @@ def increment_submissions(user_id, submission_id, submission_comment):
|
|
| 199 |
with open(user_fname, "r") as f:
|
| 200 |
user_submission_info = json.load(f)
|
| 201 |
todays_date = datetime.datetime.now().strftime("%Y-%m-%d")
|
|
|
|
| 202 |
user_submission_info["submissions"].append(
|
| 203 |
{
|
| 204 |
"date": todays_date,
|
| 205 |
"submission_id": submission_id,
|
| 206 |
"submission_comment": submission_comment,
|
| 207 |
"status": "pending",
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
)
|
| 210 |
# count the number of times user has submitted today
|
|
|
|
| 1 |
+
import datetime
|
| 2 |
+
import io
|
| 3 |
+
import json
|
| 4 |
import time
|
| 5 |
+
|
| 6 |
import requests
|
|
|
|
| 7 |
from huggingface_hub import HfApi, hf_hub_download
|
|
|
|
|
|
|
|
|
|
| 8 |
from huggingface_hub.utils._errors import EntryNotFoundError
|
| 9 |
|
| 10 |
+
import config
|
| 11 |
+
|
| 12 |
|
| 13 |
def get_auth_headers(token: str, prefix: str = "Bearer"):
|
| 14 |
return {"Authorization": f"{prefix} {token}"}
|
|
|
|
| 201 |
with open(user_fname, "r") as f:
|
| 202 |
user_submission_info = json.load(f)
|
| 203 |
todays_date = datetime.datetime.now().strftime("%Y-%m-%d")
|
| 204 |
+
# here goes all the default stuff for submission
|
| 205 |
user_submission_info["submissions"].append(
|
| 206 |
{
|
| 207 |
"date": todays_date,
|
| 208 |
"submission_id": submission_id,
|
| 209 |
"submission_comment": submission_comment,
|
| 210 |
"status": "pending",
|
| 211 |
+
"selected": False,
|
| 212 |
+
"public_score": -1,
|
| 213 |
+
"private_score": -1,
|
| 214 |
}
|
| 215 |
)
|
| 216 |
# count the number of times user has submitted today
|