Commit
·
add2842
1
Parent(s):
e6d7498
switching to docker sdk
Browse files- Dockerfile +20 -0
- README.md +4 -3
- metric.py +26 -1
- requirements.txt +4 -1
Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.13.5-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
build-essential \
|
| 7 |
+
curl \
|
| 8 |
+
git \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
COPY requirements.txt ./
|
| 12 |
+
COPY . .
|
| 13 |
+
|
| 14 |
+
RUN pip3 install -r requirements.txt
|
| 15 |
+
|
| 16 |
+
EXPOSE 8501
|
| 17 |
+
|
| 18 |
+
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 19 |
+
|
| 20 |
+
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
README.md
CHANGED
|
@@ -3,9 +3,10 @@ title: Video Challenge Leaderboard
|
|
| 3 |
emoji: 🏢
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: blue
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
pinned: false
|
| 10 |
short_description: Leaderboard
|
| 11 |
---
|
|
|
|
| 3 |
emoji: 🏢
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: blue
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 8501
|
| 8 |
+
tags:
|
| 9 |
+
- streamlit
|
| 10 |
pinned: false
|
| 11 |
short_description: Leaderboard
|
| 12 |
---
|
metric.py
CHANGED
|
@@ -1,8 +1,25 @@
|
|
| 1 |
from collections import defaultdict
|
|
|
|
| 2 |
from huggingface_hub import hf_hub_download
|
| 3 |
import pandas as pd
|
| 4 |
from sklearn.metrics import roc_auc_score, roc_curve
|
| 5 |
from typing import Any, Dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def compute_auc(df: pd.DataFrame) -> float:
|
|
@@ -20,10 +37,13 @@ def compute_auc(df: pd.DataFrame) -> float:
|
|
| 20 |
## Only one class
|
| 21 |
if ytrue.all() or (~ytrue).all():
|
| 22 |
return float("nan")
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
return roc_auc_score(ytrue, df["score"])
|
| 25 |
except Exception as e:
|
| 26 |
print(f"AUC exception: {e}")
|
|
|
|
| 27 |
return float("nan")
|
| 28 |
|
| 29 |
|
|
@@ -36,9 +56,14 @@ def compute_roc_curve(df: pd.DataFrame, keep_every: int = 10) -> Dict[Any, Any]:
|
|
| 36 |
return {"fpr": [], "tpr": [], "threshold": []}
|
| 37 |
|
| 38 |
df = df.loc[~isna]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
fpr, tpr, threshold = roc_curve(df["pred"] == "generated", df["score"])
|
| 40 |
if len(fpr) < keep_every:
|
| 41 |
return {"fpr": fpr.tolist(), "tpr": tpr.tolist(), "threshold": threshold.tolist()}
|
|
|
|
| 42 |
|
| 43 |
# Sample every keep_every
|
| 44 |
return {
|
|
|
|
| 1 |
from collections import defaultdict
|
| 2 |
+
import traceback
|
| 3 |
from huggingface_hub import hf_hub_download
|
| 4 |
import pandas as pd
|
| 5 |
from sklearn.metrics import roc_auc_score, roc_curve
|
| 6 |
from typing import Any, Dict
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def check_if_score_ok(df):
|
| 11 |
+
if df["score"].min() >= .5 and df["score"].max() <= 1.:
|
| 12 |
+
print("assuming max prob is reported... recomputing")
|
| 13 |
+
## assume in this case they are reporting max P(real), P(generated)
|
| 14 |
+
pred_generated = df["submission_pred"] == "generated"
|
| 15 |
+
pred_real = df["submission_pred"] == "real"
|
| 16 |
+
|
| 17 |
+
df.loc[pred_real, "score"] = 1. - df.loc[pred_real, "score"]
|
| 18 |
+
not_predicted = ~(pred_generated | pred_real)
|
| 19 |
+
if not_predicted.any():
|
| 20 |
+
df.loc[not_predicted,"score"] = np.random.rand(not_predicted.sum())
|
| 21 |
+
|
| 22 |
+
return df
|
| 23 |
|
| 24 |
|
| 25 |
def compute_auc(df: pd.DataFrame) -> float:
|
|
|
|
| 37 |
## Only one class
|
| 38 |
if ytrue.all() or (~ytrue).all():
|
| 39 |
return float("nan")
|
| 40 |
+
|
| 41 |
+
df = check_if_score_ok(df)
|
| 42 |
+
|
| 43 |
return roc_auc_score(ytrue, df["score"])
|
| 44 |
except Exception as e:
|
| 45 |
print(f"AUC exception: {e}")
|
| 46 |
+
# traceback.print_exc()
|
| 47 |
return float("nan")
|
| 48 |
|
| 49 |
|
|
|
|
| 56 |
return {"fpr": [], "tpr": [], "threshold": []}
|
| 57 |
|
| 58 |
df = df.loc[~isna]
|
| 59 |
+
|
| 60 |
+
df = check_if_score_ok(df)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
fpr, tpr, threshold = roc_curve(df["pred"] == "generated", df["score"])
|
| 64 |
if len(fpr) < keep_every:
|
| 65 |
return {"fpr": fpr.tolist(), "tpr": tpr.tolist(), "threshold": threshold.tolist()}
|
| 66 |
+
|
| 67 |
|
| 68 |
# Sample every keep_every
|
| 69 |
return {
|
requirements.txt
CHANGED
|
@@ -2,4 +2,7 @@ scikit-learn
|
|
| 2 |
numpy
|
| 3 |
streamlit
|
| 4 |
huggingface_hub
|
| 5 |
-
pytz
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
numpy
|
| 3 |
streamlit
|
| 4 |
huggingface_hub
|
| 5 |
+
pytz
|
| 6 |
+
altair
|
| 7 |
+
pandas
|
| 8 |
+
hf_transfer
|