patrickvonplaten commited on
Commit
7f83c31
1 Parent(s): a7e7106

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -35,6 +35,22 @@ submission_names = list(SUBMISSIONS.keys())
35
  num_images = len(SUBMISSIONS[submission_names[0]])
36
 
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  def generate_random_hash(length=8):
39
  """
40
  Generates a random hash of specified length.
@@ -53,18 +69,7 @@ def generate_random_hash(length=8):
53
  random_hash = secrets.token_hex(num_bytes)
54
 
55
  return random_hash
56
-
57
- def load_submissions():
58
- all_datasets = list_datasets(author=SUBMISSION_ORG)
59
- relevant_ids = [d.id for d in all_datasets]
60
-
61
- submitted_ids = []
62
- for _id in relevant_ids:
63
- ds = load_dataset(_id)["train"]
64
- submitted_ids += ds["id"]
65
 
66
- submitted_ids = Counter(submitted_ids)
67
- return submitted_ids
68
 
69
  def refresh(row_number, dataframe):
70
  if row_number == NUM_QUESTIONS:
@@ -73,12 +78,9 @@ def refresh(row_number, dataframe):
73
  else:
74
  return dataframe
75
 
76
- def start(submitted_ids=None):
77
- if submitted_ids is None:
78
- submitted_ids = load_submissions()
79
-
80
  ids = {id: 0 for id in range(num_images)}
81
- ids = {**ids, **submitted_ids}
82
 
83
  # sort by count
84
  ids = sorted(ids.items(), key=lambda x: x[1])
 
35
  num_images = len(SUBMISSIONS[submission_names[0]])
36
 
37
 
38
+ def load_submissions():
39
+ all_datasets = list_datasets(author=SUBMISSION_ORG)
40
+ relevant_ids = [d.id for d in all_datasets]
41
+
42
+ submitted_ids = []
43
+ for _id in relevant_ids:
44
+ ds = load_dataset(_id)["train"]
45
+ submitted_ids += ds["id"]
46
+
47
+ submitted_ids = Counter(submitted_ids)
48
+ return submitted_ids
49
+
50
+
51
+ SUBMITTED_IDS = load_submissions()
52
+
53
+
54
  def generate_random_hash(length=8):
55
  """
56
  Generates a random hash of specified length.
 
69
  random_hash = secrets.token_hex(num_bytes)
70
 
71
  return random_hash
 
 
 
 
 
 
 
 
 
72
 
 
 
73
 
74
  def refresh(row_number, dataframe):
75
  if row_number == NUM_QUESTIONS:
 
78
  else:
79
  return dataframe
80
 
81
+ def start():
 
 
 
82
  ids = {id: 0 for id in range(num_images)}
83
+ ids = {**ids, **SUBMITTED_IDS}
84
 
85
  # sort by count
86
  ids = sorted(ids.items(), key=lambda x: x[1])