src/constants.py CHANGED
@@ -5,7 +5,7 @@ import os
5
  import pathlib
6
 
7
 
8
- DATASET_NAME = "Xmaster6y/fruit-vegetable-concepts"
9
  CONCEPTS = [
10
  # Shapes
11
  "sphere",
 
5
  import pathlib
6
 
7
 
8
+ DATASET_NAME = "mulsi/fruit-vegetable-concepts"
9
  CONCEPTS = [
10
  # Shapes
11
  "sphere",
src/global_variables.py CHANGED
@@ -78,7 +78,8 @@ def update_votes(
78
  all_votes[s_id] = {}
79
  all_votes[s_id][username] = {c: c in voted_concepts for c in CONCEPTS}
80
  new_concepts = compute_concepts(all_votes[s_id])
81
- all_metadata[current_split][idx]["concepts"] = new_concepts
 
82
 
83
  def compute_concepts(votes):
84
  vote_sum = {c: 0 for c in CONCEPTS}
@@ -122,7 +123,7 @@ def save_current_work(
122
  for row in reader:
123
  s_id = row["id"]
124
  if s_id in all_votes:
125
- row["concepts"] = compute_concepts(all_votes[s_id])
126
  new_metadata[split].append(row)
127
  with jsonlines.open(f"{ASSETS_FOLDER}/{DATASET_NAME}/data/{split}/metadata.jsonl", mode='w') as writer:
128
  writer.write_all(new_metadata[split])
 
78
  all_votes[s_id] = {}
79
  all_votes[s_id][username] = {c: c in voted_concepts for c in CONCEPTS}
80
  new_concepts = compute_concepts(all_votes[s_id])
81
+ for concept, concept_value in new_concepts.items():
82
+ all_metadata[current_split][idx][concept] = concept_value
83
 
84
  def compute_concepts(votes):
85
  vote_sum = {c: 0 for c in CONCEPTS}
 
123
  for row in reader:
124
  s_id = row["id"]
125
  if s_id in all_votes:
126
+ row.update(compute_concepts(all_votes[s_id]))
127
  new_metadata[split].append(row)
128
  with jsonlines.open(f"{ASSETS_FOLDER}/{DATASET_NAME}/data/{split}/metadata.jsonl", mode='w') as writer:
129
  writer.write_all(new_metadata[split])
src/label_interface.py CHANGED
@@ -12,7 +12,7 @@ from src.constants import CONCEPTS, ASSETS_FOLDER, DATASET_NAME
12
 
13
 
14
  def filter_sample(sample, concepts, username, sample_type):
15
- has_concepts = all([sample["concepts"].get(c, False) for c in concepts])
16
  if not has_concepts:
17
  return False
18
  if "votes" in sample and username in sample["votes"]:
@@ -53,14 +53,14 @@ def get_next_image(
53
  except KeyError:
54
  voted_concepts = []
55
  unseen_concepts = []
56
- tie_concepts = [c for c in sample["concepts"] if sample["concepts"][c] is None]
57
 
58
  return (
59
  image_path,
60
  voted_concepts,
61
  f"{split}:{sample_idx}",
62
  sample["class"],
63
- sample["concepts"],
64
  unseen_concepts,
65
  tie_concepts,
66
  filtered_indices,
 
12
 
13
 
14
  def filter_sample(sample, concepts, username, sample_type):
15
+ has_concepts = all([sample[c] for c in concepts])
16
  if not has_concepts:
17
  return False
18
  if "votes" in sample and username in sample["votes"]:
 
53
  except KeyError:
54
  voted_concepts = []
55
  unseen_concepts = []
56
+ tie_concepts = [c for c in CONCEPTS if sample[c] is None]
57
 
58
  return (
59
  image_path,
60
  voted_concepts,
61
  f"{split}:{sample_idx}",
62
  sample["class"],
63
+ {c: sample[c] for c in CONCEPTS},
64
  unseen_concepts,
65
  tie_concepts,
66
  filtered_indices,
src/sample_interface.py CHANGED
@@ -37,14 +37,14 @@ def get_image(
37
  except KeyError:
38
  voted_concepts = []
39
  unseen_concepts = []
40
- tie_concepts = [c for c in sample["concepts"] if sample["concepts"][c] is None]
41
 
42
  return (
43
  image_path,
44
  voted_concepts,
45
  f"{split}:{sample_idx}",
46
  sample["class"],
47
- sample["concepts"],
48
  str(sample_idx),
49
  unseen_concepts,
50
  tie_concepts,
 
37
  except KeyError:
38
  voted_concepts = []
39
  unseen_concepts = []
40
+ tie_concepts = [c for c in CONCEPTS if sample[c] is None]
41
 
42
  return (
43
  image_path,
44
  voted_concepts,
45
  f"{split}:{sample_idx}",
46
  sample["class"],
47
+ {c: sample[c] for c in CONCEPTS},
48
  str(sample_idx),
49
  unseen_concepts,
50
  tie_concepts,