michelecafagna26 commited on
Commit
43fd754
1 Parent(s): 12d0b6c

Update hl.py

Browse files
Files changed (1) hide show
  1. hl.py +13 -12
hl.py CHANGED
@@ -116,15 +116,16 @@ class HL(datasets.GeneratorBasedBuilder):
116
  # Annotation files come first, then the images.
117
  for img_file_path, img_obj in images:
118
 
119
- file_name = Path(img_file_path).name
120
-
121
- yield idx, {
122
- "file_name": file_name,
123
- "image": {"path": img_file_path, "bytes": img_obj.read()},
124
- "scene": metadata[file_name]['captions']['scene'],
125
- "action": metadata[file_name]['captions']['action'],
126
- "rationale": metadata[file_name]['captions']['rationale'],
127
- "object": metadata[file_name]['captions']['object'],
128
- "confidence": metadata[file_name]['confidence'],
129
- }
130
- idx += 1
 
 
116
  # Annotation files come first, then the images.
117
  for img_file_path, img_obj in images:
118
 
119
+ if img_file_path in metadata:
120
+ file_name = Path(img_file_path).name
121
+
122
+ yield idx, {
123
+ "file_name": file_name,
124
+ "image": {"path": img_file_path, "bytes": img_obj.read()},
125
+ "scene": metadata[file_name]['captions']['scene'],
126
+ "action": metadata[file_name]['captions']['action'],
127
+ "rationale": metadata[file_name]['captions']['rationale'],
128
+ "object": metadata[file_name]['captions']['object'],
129
+ "confidence": metadata[file_name]['confidence'],
130
+ }
131
+ idx += 1