detectors.data package

Submodules

detectors.data.cifar_wrapper module

class detectors.data.cifar_wrapper.CIFAR100Wrapped(root: str, split: str = 'test', transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: CIFAR100

splits = ('train', 'test')
class detectors.data.cifar_wrapper.CIFAR10Wrapped(root: str, split: str = 'test', transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: CIFAR10

splits = ('train', 'test')

detectors.data.cifarc module

class detectors.data.cifarc.CIFAR100_C(root: str, split: str, intensity: int, transform: Callable | None = None, download: bool = False)[source]

Bases: CIFAR10_C

base_folder = 'CIFAR-100-C'
corruptions = ['brightness', 'contrast', 'defocus_blur', 'elastic_transform', 'fog', 'frost', 'gaussian_blur', 'gaussian_noise', 'glass_blur', 'impulse_noise', 'jpeg_compression', 'motion_blur', 'pixelate', 'saturate', 'shot_noise', 'snow', 'spatter', 'speckle_noise', 'zoom_blur']
file_md5 = '11f0ed0f1191edbf9fa23466ae6021d3'
filename = 'CIFAR-100-C.tar'
url = 'https://zenodo.org/record/3555552/files/CIFAR-100-C.tar'
class detectors.data.cifarc.CIFAR10_C(root: str, split: str, intensity: int, transform: Callable | None = None, download: bool = False)[source]

Bases: Dataset

base_folder = 'CIFAR-10-C'
corruptions = ['brightness', 'contrast', 'defocus_blur', 'elastic_transform', 'fog', 'frost', 'gaussian_blur', 'gaussian_noise', 'glass_blur', 'impulse_noise', 'jpeg_compression', 'motion_blur', 'pixelate', 'saturate', 'shot_noise', 'snow', 'spatter', 'speckle_noise', 'zoom_blur']
download() None[source]
file_md5 = '56bf5dcef84df0e2308c6dcbcbbd8499'
filename = 'CIFAR-10-C.tar'
url = 'https://zenodo.org/record/2535967/files/CIFAR-10-C.tar'

detectors.data.cifarlt module

Adapted from https://github.com/Megvii-Nanjing/BBN

class detectors.data.cifarlt.CIFAR100LT(root: str, train: bool, transform: Callable | None = None, target_transform: Callable | None = None, download=True, imbalance_ratio=0.01, imb_type: Literal['exp', 'step'] = 'exp')[source]

Bases: CIFAR10LT

base_folder = 'cifar-100-python'
cls_num = 100
filename = 'cifar-100-python.tar.gz'
meta = {'filename': 'meta', 'key': 'fine_label_names', 'md5': '7973b15100ade9c7d40fb424638fde48'}
test_list = [['test', 'f0ef6b0ae62326f3e7ffdfab6717acfc']]
tgz_md5 = 'eb9058c3a382ffc7106e4002c42a8d85'
train_list = [['train', '16019d7e3df5f24257cddd939b257f8d']]
url = 'https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
class detectors.data.cifarlt.CIFAR10LT(root: str, train: bool, transform: Callable | None = None, target_transform: Callable | None = None, download=True, imbalance_ratio=0.01, imb_type: Literal['exp', 'step'] = 'exp')[source]

Bases: CIFAR10

cls_num = 10
detectors.data.cifarlt.test()[source]

detectors.data.constants module

detectors.data.english_chars module

class detectors.data.english_chars.EnglishChars(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

In the English language, Latin script (excluding accents) and Hindu-Arabic numerals are used. For simplicity we call this the β€œEnglish” characters set. The dataset consists of:

  • 64 classes (0-9, A-Z, a-z)

  • 7705 characters obtained from natural images

  • 3410 hand drawn characters using a tablet PC

  • 62992 synthesised characters from computer fonts

  • This gives a total of over 74K images (which explains the name of the dataset).

base_folder = 'chars74k'
download() None[source]
file_md5 = '85d157e0c58f998e1cda8def62bcda0d'
filename = 'EnglishImg.tgz'
images_folder = 'English/Img/GoodImg/Bmp/'
url = 'http://www.ee.surrey.ac.uk/CVSSP/demos/chars74k/EnglishImg.tgz'

detectors.data.imagenet module

class detectors.data.imagenet.ImageNetA(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

ImageNetA dataset.

base_folder = 'imagenet-a'
download() None[source]
filename = 'imagenet-a.tar'
tgz_md5 = 'c3e55429088dc681f30d81f4726b6595'
url = 'https://people.eecs.berkeley.edu/~hendrycks/imagenet-a.tar'
class detectors.data.imagenet.ImageNetC(root: str, split: str, intensity: int, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageNetA

Corrupted version of the ImageNet-1k dataset.

It contains the following subsets:

  • noise (21GB): gaussian_noise, shot_noise, and impulse_noise.

  • blur (7GB): defocus_blur, glass_blur, motion_blur, and zoom_blur.

  • weather (12GB): frost, snow, fog, and brightness.

  • digital (7GB): contrast, elastic_transform, pixelate, and jpeg_compression.

  • extra (15GB): speckle_noise, spatter, gaussian_blur, and saturate.

  • Paper: [https://arxiv.org/abs/1903.12261v1](https://arxiv.org/abs/1903.12261v1)

base_folder_name = 'ImageNetC'
corruptions = ['brightness', 'contrast', 'defocus_blur', 'elastic_transform', 'fog', 'frost', 'gaussian_blur', 'gaussian_noise', 'glass_blur', 'impulse_noise', 'jpeg_compression', 'motion_blur', 'pixelate', 'saturate', 'shot_noise', 'snow', 'spatter', 'speckle_noise', 'zoom_blur']
download() None[source]
split_list = ['blur', 'digital', 'extra', 'noise', 'weather']
tgz_md5_list = ['2d8e81fdd8e07fef67b9334fa635e45c', '89157860d7b10d5797849337ca2e5c03', 'd492dfba5fc162d8ec2c3cd8ee672984', 'e80562d7f6c3f8834afb1ecf27252745', '33ffea4db4d93fe4a428c40a6ce0c25d']
url_base = 'https://zenodo.org/record/2235448/files/'
class detectors.data.imagenet.ImageNetCnpz(root: str, split: str, intensity: int, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: Dataset

Corrupted version of the ImageNet-1k dataset saved in npz format.

base_folder_name = 'ImageNetCnpz'
corruptions = ['brightness', 'contrast', 'defocus_blur', 'elastic_transform', 'fog', 'frost', 'gaussian_blur', 'gaussian_noise', 'glass_blur', 'impulse_noise', 'jpeg_compression', 'motion_blur', 'pixelate', 'saturate', 'shot_noise', 'snow', 'spatter', 'speckle_noise', 'zoom_blur']
download() None[source]
class detectors.data.imagenet.ImageNetO(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageNetA

ImageNetO datasets.

Contains unknown classes to ImageNet-1k.

base_folder = 'imagenet-o'
filename = 'imagenet-o.tar'
tgz_md5 = '86bd7a50c1c4074fb18fc5f219d6d50b'
url = 'https://people.eecs.berkeley.edu/~hendrycks/imagenet-o.tar'
class detectors.data.imagenet.ImageNetR(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageNetA

ImageNet-R(endition) dataset.

Contains art, cartoons, deviantart, graffiti, embroidery, graphics, origami, paintings, patterns, plastic objects,plush objects, sculptures, sketches, tattoos, toys, and video game renditions of ImageNet-1k classes.

base_folder = 'imagenet-r'
filename = 'imagenet-r.tar'
tgz_md5 = 'a61312130a589d0ca1a8fca1f2bd3337'
url = 'https://people.eecs.berkeley.edu/~hendrycks/imagenet-r.tar'

detectors.data.imagenetlt module

From https://github.com/KaihuaTang/Long-Tailed-Recognition.pytorch/blob/master/classification/data/dataloader.py

class detectors.data.imagenetlt.LT_Dataset(root: str, txt_path: str, subset_class_idx=array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999]), transform=None)[source]

Bases: Dataset

detectors.data.isun module

class detectors.data.isun.iSUN(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

iSUN Dataset subset.

Parameters:
  • root (string) – Root directory of dataset where directory exists or will be saved to if download is set to True.

  • split (string, optional) – The dataset split, not used.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments passed to ImageFolder.

base_folder = 'iSUN'
download() None[source]
file_md5 = 'be77b0f2c26fda898afac5f99645ee70'
filename = 'iSUN.tar.gz'
url = 'https://www.dropbox.com/s/ssz7qxfqae0cca5/iSUN.tar.gz'

detectors.data.lsun_r_c module

class detectors.data.lsun_r_c.LSUNCroped(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: LSUNResized

LSUN (c) Dataset subset.

Parameters:
  • root (string) – Root directory of dataset where directory exists or will be saved to if download is set to True.

  • split (string, optional) – The dataset split, not used.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments passed to ImageFolder.

base_folder = 'LSUN_croped'
file_md5 = '458a0a0ab8e5f1cb4516d7400568e460'
filename = 'LSUN.tar.gz'
url = 'https://www.dropbox.com/s/fhtsw1m3qxlwj6h/LSUN.tar.gz'
class detectors.data.lsun_r_c.LSUNResized(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

LSUN (r) Dataset subset.

Parameters:
  • root (string) – Root directory of dataset where directory exists or will be saved to if download is set to True.

  • split (string, optional) – The dataset split, not used.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments passed to ImageFolder.

base_folder = 'LSUN_resized'
download() None[source]
file_md5 = '278b7b31c8cb7e804a1465a8ce03a2dc'
filename = 'LSUN_resize.tar.gz'
url = 'https://www.dropbox.com/s/moqh2wh8696c3yl/LSUN_resize.tar.gz'

detectors.data.mnist_wrapped module

class detectors.data.mnist_wrapped.FashionMNISTWrapped(root: str, split: str = 'test', transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: FashionMNIST

splits = ('train', 'test')
class detectors.data.mnist_wrapped.MNISTWrapped(root: str, split: str = 'test', transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: MNIST

splits = ('train', 'test')

detectors.data.mnistc module

class detectors.data.mnistc.MNISTC(root: str, corruption: str, split: str, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: object

MNIST-C is MNIST with corruptions for benchmarking OOD methods.

Split can be one of train, test and leftovers.

Subsets can be one of:

all, brightness, canny_edges, dotted_line, fog, glass_blur, identity, impulse_noise, motion_blur, rotate, scale, shear, shot_noise, spatter, stripe, translate and zigzag.

base_folders = ['mnist_c', 'mnist_c_leftovers']
download() None[source]
filenames = ['mnist_c.zip', 'mnist_c_leftovers.zip']
splits = ['train', 'test', 'leftovers']
subsets = ['brightness', 'canny_edges', 'dotted_line', 'fog', 'glass_blur', 'identity', 'impulse_noise', 'motion_blur', 'rotate', 'scale', 'shear', 'shot_noise', 'spatter', 'stripe', 'translate', 'zigzag']
tgz_md5s = ['4b34b33045869ee6d424616cd3a65da3', 'c365e9c25addd5c24454b19ac7101070']
urls = ['https://zenodo.org/record/3239543/files/mnist_c.zip', 'https://zenodo.org/record/3239543/files/mnist_c_leftovers.zip']

detectors.data.mos module

class detectors.data.mos.MOSPlaces365(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: MOSSUN

MOS Places365 Dataset subset.

Parameters:
  • root (string) – Root directory of dataset where directory exists or will be saved to if download is set to True.

  • split (string, optional) – The dataset split, not used.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments passed to ImageFolder.

base_folder = 'mos_places365'
file_md5 = 'b5cb5eba2754ae2a28beea8718db699a'
filename = 'Places.tar.gz'
url = 'http://pages.cs.wisc.edu/~huangrui/imagenet_ood_dataset/Places.tar.gz'
class detectors.data.mos.MOSSUN(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

MOS SUN Dataset subset.

Parameters:
  • root (string) – Root directory of dataset where directory exists or will be saved to if download is set to True.

  • split (string, optional) – The dataset split, not used.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments passed to ImageFolder.

base_folder = 'mos_sun'
download() None[source]
file_md5 = '8469c3ada62211477954ec1be53b12d0'
filename = 'SUN.tar.gz'
url = 'http://pages.cs.wisc.edu/~huangrui/imagenet_ood_dataset/SUN.tar.gz'
class detectors.data.mos.MOSiNaturalist(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: MOSSUN

MOS iNaturalist Dataset subset.

Parameters:
  • root (string) – Root directory of dataset where directory exists or will be saved to if download is set to True.

  • split (string, optional) – The dataset split, not used.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop.

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments passed to ImageFolder.

base_folder = 'mos_inaturalist'
file_md5 = '5be6ea8aa027d7b631916427b32cb335'
filename = 'iNaturalist.tar.gz'
url = 'http://pages.cs.wisc.edu/~huangrui/imagenet_ood_dataset/iNaturalist.tar.gz'

detectors.data.noise module

class detectors.data.noise.Blobs(root: str | None = None, split: str | None = None, transform: Callable | None = None, download: bool = False, nb_samples=10000, shape: Tuple[int, int, int] = (224, 224, 3), seed=1, **kwargs)[source]

Bases: CustomTensorDataset

class detectors.data.noise.CustomTensorDataset(*tensors, transform=None)[source]

Bases: Dataset

TensorDataset with support for transformations.

Parameters:
  • *tensors (Tensor) – tensors that have the same size of the first dimension.

  • transform (callable, optional) – transform to apply.

class detectors.data.noise.Gaussian(root: str | None = None, split: str | None = None, transform: Callable | None = None, download: bool = False, nb_samples=10000, shape: Tuple[int, int, int] = (224, 224, 3), seed=1, **kwargs)[source]

Bases: CustomTensorDataset

Gaussian noise dataset.

Parameters:
  • root (str) – root directory.

  • split (str, optional) – not used.

  • transform (callable, optional) – transform to apply.

  • download (bool, optional) – not used.

  • nb_samples (int) – number of samples.

  • shape (tuple[int, int, int]) – shape of the samples.

  • seed (int) – seed for the random number generator.

class detectors.data.noise.Rademacher(root: str | None = None, split: str | None = None, transform: Callable | None = None, download: bool = False, nb_samples=10000, shape: Tuple[int, int, int] = (224, 224, 3), seed=1, **kwargs)[source]

Bases: CustomTensorDataset

class detectors.data.noise.Uniform(root: str | None = None, split: str | None = None, transform: Callable | None = None, download: bool = False, nb_samples=10000, shape: Tuple[int, int, int] = (224, 224, 3), seed=1, **kwargs)[source]

Bases: CustomTensorDataset

Uniform noise dataset.

Parameters:
  • root (str) – root directory.

  • split (str, optional) – not used.

  • transform (callable, optional) – transform to apply.

  • download (bool, optional) – not used.

  • nb_samples (int) – number of samples.

  • shape (tuple[int, int, int]) – shape of the samples.

  • seed (int) – seed for the random number generator.

detectors.data.openimage_o module

class detectors.data.openimage_o.OpenImageO(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

OpenImageO dataset.

  • Length: <17632

    (sore url returns http error code 404. Might need to invoke several times to get at lkeas 16k images). Confirmed 16067 images.

  • Size: >30GB

  • Paper: https://arxiv.org/pdf/2203.10807.pdf

  • Auxiliary file: OpenImageO/openimage_o_urls.csv

Args:

base_folder = 'openimage-o'
download() None[source]
filenames = 'OpenImageO/openimage_o_urls.csv'

detectors.data.places365 module

class detectors.data.places365.Places365(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

base_folder = 'places365'
download() None[source]
file_md5 = 'e27b17d8d44f4af9a78502beb927f808'
filename = 'val_256.tar'
url = 'http://data.csail.mit.edu/places/places365/val_256.tar'

detectors.data.textures module

class detectors.data.textures.Textures(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

DTD is a texture database, consisting of 5640 images, organized according to a list of 47 terms (categories) inspired from human perception. There are 120 images for each category. Image sizes range between 300x300 and 640x640, and the images contain at least 90% of the surface representing the category attribute. The images were collected from Google and Flickr by entering our proposed attributes and related terms as search queries.

base_folder = 'textures'
property dataset_folder
download() None[source]
file_md5 = 'fff73e5086ae6bdbea199a49dfb8a4c1'
filename = 'dtd-r1.0.1.tar.gz'
images_folder = 'dtd/images'
property split_folder
url = 'https://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gz'

detectors.data.tiny_imagenet module

Simple Tiny ImageNet dataset utility class for pytorch.

class detectors.data.tiny_imagenet.TinyImageNet(root, split='train', transform: Callable | None = None, download=False, **kwargs)[source]

Bases: ImageFolder

Dataset for TinyImageNet-200

base_folder = 'tiny-imagenet-200'
property dataset_folder
download()[source]
extra_repr()[source]
filename = 'tiny-imagenet-200.zip'
property split_folder
splits = ('train', 'val', 'test')
url = 'http://cs231n.stanford.edu/tiny-imagenet-200.zip'
zip_md5 = '90528d7ca1a48142e341f4ef8d21d0de'
detectors.data.tiny_imagenet.normalize_tin_val_folder_structure(path, images_folder='images', annotations_file='val_annotations.txt')[source]

detectors.data.tiny_imagenet_r_c module

class detectors.data.tiny_imagenet_r_c.TinyImageNetCroped(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: TinyImageNetResized

base_folder = 'Imagenet_croped'
file_md5 = '7c0827e4246c3718a5ee076e999e52e5'
filename = 'Imagenet.tar.gz'
url = 'https://www.dropbox.com/s/avgm2u562itwpkl/Imagenet.tar.gz'
class detectors.data.tiny_imagenet_r_c.TinyImageNetResized(root: str, split=None, transform: Callable | None = None, download: bool = False, **kwargs)[source]

Bases: ImageFolder

base_folder = 'Imagenet_resized'
download() None[source]
file_md5 = '0f9ff11d45babf2eff5fe12281d1ac31'
filename = 'Imagenet_resize.tar.gz'
url = 'https://www.dropbox.com/s/kp3my3412u5k9rl/Imagenet_resize.tar.gz'

detectors.data.wilds_ds module

detectors.data.wilds_ds.make_wilds_dataset(dataset_name, root, split='train', transform: Callable | None = None, download=False, **kwargs)[source]

Module contents

Datasets module.

class detectors.data.DatasetsRegistry(value)

Bases: Enum

An enumeration.

blobs = 'blobs'
cifar10 = 'cifar10'
cifar100 = 'cifar100'
cifar100_c = 'cifar100_c'
cifar10_c = 'cifar10_c'
english_chars = 'english_chars'
fashion_mnist = 'fashion_mnist'
gaussian = 'gaussian'
ilsvrc2012 = 'ilsvrc2012'
imagenet = 'imagenet'
imagenet1k = 'imagenet1k'
imagenet1k_c = 'imagenet1k_c'
imagenet_a = 'imagenet_a'
imagenet_c = 'imagenet_c'
imagenet_c_npz = 'imagenet_c_npz'
imagenet_o = 'imagenet_o'
imagenet_r = 'imagenet_r'
isun = 'isun'
lsun_c = 'lsun_c'
lsun_r = 'lsun_r'
mnist = 'mnist'
mnist_c = 'mnist_c'
mos_inaturalist = 'mos_inaturalist'
mos_places365 = 'mos_places365'
mos_sun = 'mos_sun'
openimage_o = 'openimage_o'
oxford_pets = 'oxford_pets'
places365 = 'places365'
rademacher = 'rademacher'
stanford_cars = 'stanford_cars'
stl10 = 'stl10'
svhn = 'svhn'
textures = 'textures'
tiny_imagenet = 'tiny_imagenet'
tiny_imagenet_c = 'tiny_imagenet_c'
tiny_imagenet_r = 'tiny_imagenet_r'
uniform = 'uniform'
wilds_camelyon17 = 'wilds_camelyon17'
wilds_fmow = 'wilds_fmow'
wilds_globalwheat = 'wilds_globalwheat'
wilds_iwildcam = 'wilds_iwildcam'
wilds_poverty = 'wilds_poverty'
wilds_rxrx1 = 'wilds_rxrx1'
detectors.data.create_dataset(dataset_name: str, root: str = '/home/docs/checkouts/readthedocs.org/user_builds/detectors/checkouts/latest/data/', split: str | None = 'train', transform: Callable | None = None, download: bool | None = True, **kwargs)[source]

Create dataset factory.

Parameters:
  • dataset_name (string) –

    Name of the dataset. Already implemented:

    cifar10, cifar100, stl10, svhn, mnist, fashion_mnist, kmnist, emnist, mnist_c, english_chars, isun, lsun_c, lsun_r, tiny_imagenet_c, tiny_imagenet_r, tiny_imagenet, textures, gaussian, uniform, places365, stanford_cars, imagenet, imagenet1k, ilsvrc2012, mos_inaturalist, mos_places365, mos_sun, cifar10_lt, cifar100_lt, imagenet1k_lt, cifar10_c, cifar100_c, imagenet_c, imagenet_c_npz, imagenet_a, imagenet_r, imagenet_o, openimage_o, oxford_pets, oxford_flowers, cub200, imagenet1k_c, blobs, rademacher, wilds_iwildcam, wilds_fmow, wilds_camelyon17, wilds_rxrx1, wilds_poverty, wilds_globalwheat.

  • root (string) – Root directory of dataset.

  • split (string, optional) – Depends on the selected dataset.

  • transform (callable, optional) – A function/transform that takes in an PIL image and returns a transformed version. E.g, transforms.RandomCrop

  • download (bool, optional) – If true, downloads the dataset from the internet and puts it in root directory. If dataset is already downloaded, it is not downloaded again.

  • **kwargs – Additional arguments for dataset.

Raises:

ValueError – If dataset name is not specified.

Returns:

Dataset object.

Return type:

Dataset

detectors.data.get_dataset_cls(dataset_name: str) Type[Dataset][source]

Return dataset class by name.

Parameters:

dataset_name (string) – Name of the dataset.

Raises:

ValueError – If dataset name is not available in datasets_registry.

Returns:

Dataset class.

Return type:

Dataset

detectors.data.list_datasets() List[str][source]

List of available dataset names, sorted alphabetically.

Returns:

List of available dataset names.

Return type:

list

detectors.data.register_dataset(dataset_name: str)[source]

Register a dataset on the datasets_registry.

Parameters:

dataset_name (str) – Name of the dataset.

Example:

@register_dataset("my_dataset")
class MyDataset(Dataset):
    ...

dataset = create_dataset("my_dataset")