zhuchi76 commited on
Commit
01c00fe
·
verified ·
1 Parent(s): 3cd2f6c

Update script to hub

Browse files
Files changed (1) hide show
  1. Boat_dataset.py +17 -10
Boat_dataset.py CHANGED
@@ -138,14 +138,14 @@ class BoatDataset(datasets.GeneratorBasedBuilder):
138
  "split": "val",
139
  },
140
  ),
141
- # datasets.SplitGenerator(
142
- # name=datasets.Split.VALIDATION,
143
- # # These kwargs will be passed to _generate_examples
144
- # gen_kwargs={
145
- # "filepath": os.path.join(data_dir, "instances_val2023r.jsonl"),
146
- # "split": "val_real",
147
- # },
148
- # ),
149
  # datasets.SplitGenerator(
150
  # name=datasets.Split.TEST,
151
  # # These kwargs will be passed to _generate_examples
@@ -161,8 +161,15 @@ class BoatDataset(datasets.GeneratorBasedBuilder):
161
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
162
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
163
  with open(filepath, encoding="utf-8") as f:
164
- for key, row in enumerate(f):
165
- data = json.loads(row)
 
 
 
 
 
 
 
166
 
167
  yield key, {
168
  "image_id": data["image_id"],
 
138
  "split": "val",
139
  },
140
  ),
141
+ datasets.SplitGenerator(
142
+ name=datasets.Split.VALIDATION,
143
+ # These kwargs will be passed to _generate_examples
144
+ gen_kwargs={
145
+ "filepath": os.path.join(data_dir, "instances_val2023r.jsonl"),
146
+ "split": "val_real",
147
+ },
148
+ ),
149
  # datasets.SplitGenerator(
150
  # name=datasets.Split.TEST,
151
  # # These kwargs will be passed to _generate_examples
 
161
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
162
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
163
  with open(filepath, encoding="utf-8") as f:
164
+ for key, row in enumerate(f, 1): # Start enumeration at 1 for line numbers
165
+ try:
166
+ data = json.loads(row)
167
+ # Your existing processing logic here
168
+ except json.JSONDecodeError:
169
+ print(f"Skipping invalid JSON at line {key}")
170
+ continue
171
+ # for key, row in enumerate(f):
172
+ # data = json.loads(row)
173
 
174
  yield key, {
175
  "image_id": data["image_id"],