Spaces:
Paused
Paused
Update app.py
Browse files16 unmodified lines1718192021222310 unmodified lines343536373638394041424344455 unmodified lines51525354495055565758596061626316 unmodified lines# https://huggingface.co/datasets/ILSVRC/imagenet-1kNUM_EXAMPLES = 1281167# Arbitrary small number, only using in devv'ing (uncomment #.take(DEV_AMOUNT) below to use it).DEV = FalseDEV_AMOUNT = 10GATED_IMAGENET = os.environ.get("GATED_IMAGENET")
10 unmodified lines
# Load the dataset from the HF hub. Use streaming so as not to load the entire dataset at once. # Use the .take(DEV_AMOUNT) to only grab a small chunk of instances to develop with. if DEV: dataset = load_dataset("ILSVRC/imagenet-1k", split="train", streaming=True, dataset = load_dataset("ILSVRC/imagenet-1k", split="train", streaming=True, trust_remote_code=True, token=GATED_IMAGENET).take(DEV_AMOUNT) else: dataset = load_dataset("ILSVRC/imagenet-1k", split="train", streaming=True, trust_remote_code=True, token=GATED_IMAGENET)
# Create a set of indices that are randomly chosen, to change their labels. # Specifically, randomly choose NUM_EXAMPLES/percentage indices.5 unmodified lines features=dataset.features, batched=True)
# Upload the new version of the dataset (this will take awhile) if DEV: Dataset.from_generator(updated_dataset.__iter__).push_to_hub( "datacomp/imagenet-1k-random-debug" + str(percentage), token=GATED_IMAGENET) Dataset.from_generator(updated_dataset.__iter__).push_to_hub( "datacomp/imagenet-1k-random-debug" + str(percentage), token=GATED_IMAGENET) else: Dataset.from_generator(updated_dataset.__iter__).push_to_hub( "datacomp/imagenet-1k-random" + str(percentage), token=GATED_IMAGENET)
end = time.time() print("That took %d seconds" % (end - start))app.py+13-3