Spaces:
Paused
Paused
backup
Browse files
app.py
CHANGED
@@ -19,8 +19,8 @@ import torchvision
|
|
19 |
from huggingface_hub import HfApi, login, snapshot_download
|
20 |
from PIL import Image
|
21 |
|
22 |
-
session_token = os.environ.get("SessionToken")
|
23 |
-
login(token=session_token)
|
24 |
|
25 |
csv.field_size_limit(sys.maxsize)
|
26 |
|
@@ -83,8 +83,23 @@ def update_snapshot(username):
|
|
83 |
rows.append(tdf)
|
84 |
|
85 |
df = pd.DataFrame(rows, columns=columns)
|
86 |
-
df = df[df["user_id"] == username]
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
return df
|
89 |
|
90 |
|
|
|
19 |
from huggingface_hub import HfApi, login, snapshot_download
|
20 |
from PIL import Image
|
21 |
|
22 |
+
# session_token = os.environ.get("SessionToken")
|
23 |
+
# login(token=session_token)
|
24 |
|
25 |
csv.field_size_limit(sys.maxsize)
|
26 |
|
|
|
83 |
rows.append(tdf)
|
84 |
|
85 |
df = pd.DataFrame(rows, columns=columns)
|
|
|
86 |
|
87 |
+
# download and append all CSV files
|
88 |
+
output_dir = snapshot_download(
|
89 |
+
repo_id="taesiri/imagenet_hard_review_data_r3",
|
90 |
+
allow_patterns="*.csv",
|
91 |
+
repo_type="dataset",
|
92 |
+
)
|
93 |
+
files = glob(f"{output_dir}/*.csv")
|
94 |
+
|
95 |
+
if len(files) > 0:
|
96 |
+
csv_dataframes = [pd.read_csv(file) for file in files]
|
97 |
+
csv_dataframes = pd.concat(csv_dataframes, ignore_index=True)
|
98 |
+
df = pd.concat([df, csv_dataframes], ignore_index=True)
|
99 |
+
|
100 |
+
# remove duplicate rows
|
101 |
+
df = df.drop_duplicates(subset=["id", "user_id"], keep="last")
|
102 |
+
df = df[df["user_id"] == username]
|
103 |
return df
|
104 |
|
105 |
|