Datasets:
Tasks:
Image Classification
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
1M<n<10M
ArXiv:
License:
print -> logger.info
Browse files
ForNet.py
CHANGED
|
@@ -462,10 +462,8 @@ class ForNet(datasets.GeneratorBasedBuilder):
|
|
| 462 |
),
|
| 463 |
]
|
| 464 |
|
| 465 |
-
def _generate_examples(
|
| 466 |
-
|
| 467 |
-
): # TODO: Parallelize this with multiple tar extractor processes and also multiple recombiner processes. Iterate through imagenet in main thread only, I guess...
|
| 468 |
-
print(f"Generating examples from {len(patch_files)} patch files")
|
| 469 |
logger.info("Opening files")
|
| 470 |
class_to_zipfile = {}
|
| 471 |
for f in patch_files:
|
|
@@ -477,7 +475,7 @@ class ForNet(datasets.GeneratorBasedBuilder):
|
|
| 477 |
name_start = "/".join(name.split("/")[:-2])
|
| 478 |
if len(name_start) > 0:
|
| 479 |
name_start += "/"
|
| 480 |
-
|
| 481 |
with open(hf_indices, "r") as f:
|
| 482 |
path_to_in_idx = json.load(f)
|
| 483 |
idx_to_path = {v: k for k, v in path_to_in_idx.items()}
|
|
@@ -487,7 +485,7 @@ class ForNet(datasets.GeneratorBasedBuilder):
|
|
| 487 |
fg_bg_ratios = {"/".join(k.split("/")[-2:]).split(".")[0]: v for k, v in fg_bg_ratios.items()}
|
| 488 |
# print("fg_bg_ratios", list(fg_bg_ratios.items())[:5])
|
| 489 |
|
| 490 |
-
|
| 491 |
foraug_idx = 0
|
| 492 |
|
| 493 |
manager = multiprocessing.Manager()
|
|
@@ -556,7 +554,6 @@ class ForNet(datasets.GeneratorBasedBuilder):
|
|
| 556 |
in_proc.join()
|
| 557 |
for proc in zip_procs:
|
| 558 |
proc.join()
|
| 559 |
-
exit()
|
| 560 |
|
| 561 |
# tqdm.write("Finished all processes")
|
| 562 |
while not ret_queue.empty():
|
|
|
|
| 462 |
),
|
| 463 |
]
|
| 464 |
|
| 465 |
+
def _generate_examples(self, patch_files, split, hf_indices, cls_to_idx_loc, fg_bg_ratios):
|
| 466 |
+
logger.info(f"Generating examples from {len(patch_files)} patch files")
|
|
|
|
|
|
|
| 467 |
logger.info("Opening files")
|
| 468 |
class_to_zipfile = {}
|
| 469 |
for f in patch_files:
|
|
|
|
| 475 |
name_start = "/".join(name.split("/")[:-2])
|
| 476 |
if len(name_start) > 0:
|
| 477 |
name_start += "/"
|
| 478 |
+
logger.info(f"Loading extra information: {hf_indices}, {fg_bg_ratios}")
|
| 479 |
with open(hf_indices, "r") as f:
|
| 480 |
path_to_in_idx = json.load(f)
|
| 481 |
idx_to_path = {v: k for k, v in path_to_in_idx.items()}
|
|
|
|
| 485 |
fg_bg_ratios = {"/".join(k.split("/")[-2:]).split(".")[0]: v for k, v in fg_bg_ratios.items()}
|
| 486 |
# print("fg_bg_ratios", list(fg_bg_ratios.items())[:5])
|
| 487 |
|
| 488 |
+
logger.info("Starting extraction with ImageNet")
|
| 489 |
foraug_idx = 0
|
| 490 |
|
| 491 |
manager = multiprocessing.Manager()
|
|
|
|
| 554 |
in_proc.join()
|
| 555 |
for proc in zip_procs:
|
| 556 |
proc.join()
|
|
|
|
| 557 |
|
| 558 |
# tqdm.write("Finished all processes")
|
| 559 |
while not ret_queue.empty():
|