thomasw21
commited on
Commit
·
b5cd8c9
1
Parent(s):
ced55ee
Woops
Browse files
pmd.py
CHANGED
|
@@ -324,13 +324,11 @@ class LocalizedNarrativesOpenImagesLoader(BaseLoaderWithDLManager):
|
|
| 324 |
|
| 325 |
def _build_rows_iterator(self, chunk_size: int, annotation_file: str, split: str) -> Iterator[List[Any]]:
|
| 326 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 327 |
-
chunk = itertools.islice(fi, chunk_size)
|
| 328 |
|
| 329 |
-
|
| 330 |
-
chunk = next(chunk)
|
| 331 |
-
except StopIteration:
|
| 332 |
return
|
| 333 |
-
|
| 334 |
yield chunk
|
| 335 |
|
| 336 |
def _generate_examples(self, examples: List[Any], annotation_file: str, split: str) -> Dict[str, List[Any]]:
|
|
@@ -394,11 +392,9 @@ class LocalizedNarrativesCOCOLoader(BaseLoaderWithDLManager):
|
|
| 394 |
|
| 395 |
def _build_rows_iterator(self, chunk_size: int, annotation_file: str, base_image_path: Path) -> Iterator[List[Any]]:
|
| 396 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 397 |
-
chunk = itertools.islice(fi, chunk_size)
|
| 398 |
|
| 399 |
-
|
| 400 |
-
chunk = next(chunk)
|
| 401 |
-
except StopIteration:
|
| 402 |
return
|
| 403 |
|
| 404 |
yield chunk
|
|
@@ -473,11 +469,9 @@ class LocalizedNarrativesFlickr30kLoader(BaseLoaderWithDLManager):
|
|
| 473 |
|
| 474 |
def _build_rows_iterator(self, chunk_size: int, annotation_file: str, base_image_path: Path) -> Iterator[List[Any]]:
|
| 475 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 476 |
-
chunk = itertools.islice(fi, chunk_size)
|
| 477 |
|
| 478 |
-
|
| 479 |
-
chunk = next(chunk)
|
| 480 |
-
except StopIteration:
|
| 481 |
return
|
| 482 |
|
| 483 |
yield chunk
|
|
@@ -542,11 +536,9 @@ class LocalizedNarrativesADE20kLoader(BaseLoaderWithDLManager):
|
|
| 542 |
|
| 543 |
def _build_rows_iterator(self, annotation_file: str, base_image_path: Path, chunk_size: int) -> Iterator[List[Any]]:
|
| 544 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 545 |
-
chunk = itertools.islice(fi, chunk_size)
|
| 546 |
|
| 547 |
-
|
| 548 |
-
chunk = next(chunk)
|
| 549 |
-
except StopIteration:
|
| 550 |
return
|
| 551 |
|
| 552 |
yield chunk
|
|
|
|
| 324 |
|
| 325 |
def _build_rows_iterator(self, chunk_size: int, annotation_file: str, split: str) -> Iterator[List[Any]]:
|
| 326 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 327 |
+
chunk = tuple(itertools.islice(fi, chunk_size))
|
| 328 |
|
| 329 |
+
if not chunk:
|
|
|
|
|
|
|
| 330 |
return
|
| 331 |
+
|
| 332 |
yield chunk
|
| 333 |
|
| 334 |
def _generate_examples(self, examples: List[Any], annotation_file: str, split: str) -> Dict[str, List[Any]]:
|
|
|
|
| 392 |
|
| 393 |
def _build_rows_iterator(self, chunk_size: int, annotation_file: str, base_image_path: Path) -> Iterator[List[Any]]:
|
| 394 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 395 |
+
chunk = tuple(itertools.islice(fi, chunk_size))
|
| 396 |
|
| 397 |
+
if not chunk:
|
|
|
|
|
|
|
| 398 |
return
|
| 399 |
|
| 400 |
yield chunk
|
|
|
|
| 469 |
|
| 470 |
def _build_rows_iterator(self, chunk_size: int, annotation_file: str, base_image_path: Path) -> Iterator[List[Any]]:
|
| 471 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 472 |
+
chunk = tuple(itertools.islice(fi, chunk_size))
|
| 473 |
|
| 474 |
+
if not chunk:
|
|
|
|
|
|
|
| 475 |
return
|
| 476 |
|
| 477 |
yield chunk
|
|
|
|
| 536 |
|
| 537 |
def _build_rows_iterator(self, annotation_file: str, base_image_path: Path, chunk_size: int) -> Iterator[List[Any]]:
|
| 538 |
with open(annotation_file, "r", encoding="utf-8") as fi:
|
| 539 |
+
chunk = tuple(itertools.islice(fi, chunk_size))
|
| 540 |
|
| 541 |
+
if not chunk:
|
|
|
|
|
|
|
| 542 |
return
|
| 543 |
|
| 544 |
yield chunk
|