Add information about dataset size in README.md
#3
by
massaki75
- opened
It seems that the information about dataset size in each licensing category is not mentioned in either paper, project page, and huggingface repo. I believe adding this information will be helpful for those who would like to use or contribute to this dataset.
BTW, i use the following code to count the samples in three categories (commercial, noncommercial, and other):
import os
import glob
from tqdm import tqdm
import webdataset as wds
import multiprocessing as mp
def count_samples_in_tar(tar_file):
"""Count samples in a single tar file"""
dataset = wds.WebDataset(tar_file, shardshuffle=False)
return sum(1 for _ in dataset)
def count_samples_in_dataset(dataset_path, file_pattern="*.tar", num_workers=32):
"""Count the total number of samples in a webdataset."""
# Find all tar files in the directory
tar_files = sorted(glob.glob(os.path.join(dataset_path, file_pattern)))
total_samples = 0
with mp.Pool(processes=num_workers) as pool:
results = list(tqdm(
pool.imap(count_samples_in_tar, tar_files),
total=len(tar_files),
desc="Processing tar files"
))
total_samples = sum(results)
#print(results)
return total_samples
if __name__ == "__main__":
dataset_dir = "/path/to/hf/biomedica/dataset"
categories = ["commercial", "noncommercial", "other"]
for c in categories:
dataset_path = os.path.join(dataset_dir, c)
count = count_samples_in_dataset(dataset_path)
print(f"Total number of samples in {c} category: {count}")
# commercial: 17607694
# noncommercial: 5332781
# other: 1109948