Skip to content

Commit c16ae05

Browse files
committed
fixed bug where training dataset expected fine-grained attributes
1 parent cc492b4 commit c16ae05

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

tensorflow_datasets/image_classification/wake_vision/wake_vision_dataset_builder.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,31 @@ def _generate_examples(self, image_paths, metadata_path):
9797
for sample_path, sample_object in tfds.download.iter_archive(tar_file, tfds.download.ExtractMethod.TAR_STREAM):
9898
file_name = sample_path
9999

100+
if file_name not in metadata.index:
101+
continue
102+
100103
sample_metadata = metadata.loc[file_name]
101104

102105
yield file_name, {
103106
'image': sample_object,
104107
'filename': file_name,
105108
'person': sample_metadata['person'],
106-
'depiction': sample_metadata['depiction'],
107-
'body_part': sample_metadata['body_part'],
108-
'predominantly_female': sample_metadata['predominantly_female'],
109-
'predominantly_male': sample_metadata['predominantly_male'],
110-
'gender_unknown': sample_metadata['gender_unknown'],
111-
'young': sample_metadata['young'],
112-
'middle_age': sample_metadata['middle_age'],
113-
'older': sample_metadata['older'],
114-
'age_unknown': sample_metadata['age_unknown'],
115-
'near': sample_metadata['near'],
116-
'medium_distance': sample_metadata['medium_distance'],
117-
'far': sample_metadata['far'],
118-
'dark': sample_metadata['dark'],
119-
'normal_lighting': sample_metadata['normal_lighting'],
120-
'bright': sample_metadata['bright'],
121-
'person_depiction': sample_metadata['person_depiction'],
122-
'non-person_depiction': sample_metadata['non-person_depiction'],
123-
'non-person_non-depiction': sample_metadata['non-person_non-depiction'],
109+
'depiction': sample_metadata.get('depiction', -1),
110+
'body_part': sample_metadata.get('body_part', -1),
111+
'predominantly_female': sample_metadata.get('predominantly_female', -1),
112+
'predominantly_male': sample_metadata.get('predominantly_male',-1),
113+
'gender_unknown': sample_metadata.get('gender_unknown', -1),
114+
'young': sample_metadata.get('young', -1),
115+
'middle_age': sample_metadata.get('middle_age', -1),
116+
'older': sample_metadata.get('older', -1),
117+
'age_unknown': sample_metadata.get('age_unknown', -1),
118+
'near': sample_metadata.get('near', -1),
119+
'medium_distance': sample_metadata.get('medium_distance', -1),
120+
'far': sample_metadata.get('far', -1),
121+
'dark': sample_metadata.get('dark', -1),
122+
'normal_lighting': sample_metadata.get('normal_lighting', -1),
123+
'bright': sample_metadata.get('bright', -1),
124+
'person_depiction': sample_metadata.get('person_depiction', -1),
125+
'non-person_depiction': sample_metadata.get('non-person_depiction', -1),
126+
'non-person_non-depiction': sample_metadata.get('non-person_non-depiction', -1),
124127
}

0 commit comments

Comments
 (0)