blkpst commited on
Commit
e27e8f7
·
1 Parent(s): dbdf69a

normalize HF JSONL rows for parquet conversion

Browse files
data/masks/train.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
scripts/prepare_dataset.py CHANGED
@@ -94,14 +94,24 @@ def strip_image_data(json_path: str) -> None:
94
 
95
  def build_hf_annotation_row(annotation: dict, json_path: str) -> dict:
96
  """Return a JSON-serializable row for HF streaming from raw annotations."""
 
 
 
 
 
 
 
 
 
 
97
  return {
98
  "source_file": os.path.basename(json_path),
99
  "version": annotation.get("version"),
100
- "flags": annotation.get("flags", {}),
101
- "shapes": annotation.get("shapes", []),
102
  "imagePath": annotation.get("imagePath"),
103
  "imageHeight": annotation.get("imageHeight"),
104
  "imageWidth": annotation.get("imageWidth"),
 
105
  }
106
 
107
 
 
94
 
95
  def build_hf_annotation_row(annotation: dict, json_path: str) -> dict:
96
  """Return a JSON-serializable row for HF streaming from raw annotations."""
97
+ shapes = []
98
+ for shape in annotation.get("shapes", []):
99
+ shapes.append({
100
+ "label": shape.get("label"),
101
+ "shape_type": shape.get("shape_type"),
102
+ "points": shape.get("points", []),
103
+ "description": shape.get("description"),
104
+ "group_id": shape.get("group_id"),
105
+ })
106
+
107
  return {
108
  "source_file": os.path.basename(json_path),
109
  "version": annotation.get("version"),
110
+ "shapes": shapes,
 
111
  "imagePath": annotation.get("imagePath"),
112
  "imageHeight": annotation.get("imageHeight"),
113
  "imageWidth": annotation.get("imageWidth"),
114
+ "num_shapes": len(shapes),
115
  }
116
 
117