thomasw21 commited on
Commit
1a6bd7c
·
1 Parent(s): 69b5d09

Maybe I need to load everything into memory first

Browse files
Files changed (1) hide show
  1. pmd.py +5 -1
pmd.py CHANGED
@@ -467,11 +467,14 @@ class VisualGenomeLoader(DatasetsLoader):
467
 
468
  def cast_to_pmd_features(self, row: Dict) -> List[Dict[str, Any]]:
469
  meta = {k: v for k, v in row.items() if k not in ["image", "regions"]}
 
 
 
470
  rows = [
471
  {
472
  "image_url": None,
473
  # TODO @thomasw21 I believe this is slow as hell
474
- "image": row["image"].crop(
475
  (
476
  region["x"],
477
  region["y"],
@@ -489,6 +492,7 @@ class VisualGenomeLoader(DatasetsLoader):
489
  }
490
  for region in row["regions"]
491
  ]
 
492
  return rows
493
 
494
 
 
467
 
468
  def cast_to_pmd_features(self, row: Dict) -> List[Dict[str, Any]]:
469
  meta = {k: v for k, v in row.items() if k not in ["image", "regions"]}
470
+ image = row["image"]
471
+ # Maybe I need to load this into memory
472
+ image.load()
473
  rows = [
474
  {
475
  "image_url": None,
476
  # TODO @thomasw21 I believe this is slow as hell
477
+ "image": image.crop(
478
  (
479
  region["x"],
480
  region["y"],
 
492
  }
493
  for region in row["regions"]
494
  ]
495
+ image.close()
496
  return rows
497
 
498