├── .gitignore ├── README.md ├── align_uniform ├── __init__.py ├── encoder.py ├── linear_eval_imagenet100.py ├── main.py └── util.py ├── generate_datasets ├── README.md ├── dead_leaves │ ├── __init__.py │ └── generate_dataset.py ├── feature_visualizations │ ├── __init__.py │ ├── generate_dataset.py │ └── vis │ │ ├── __init__.py │ │ └── grad_ascent │ │ ├── __init__.py │ │ └── lucent │ │ ├── objectives.py │ │ ├── render.py │ │ └── transform.py ├── readme_assets │ └── all_models.jpg ├── requirements.txt ├── statistical │ ├── generate_datasets.py │ └── matlab │ │ ├── __init__.py │ │ ├── generate.sh │ │ ├── generate_datasets.m │ │ ├── image_model.m │ │ └── matlabPyrTools │ │ ├── ChangeLog │ │ ├── Contents.m │ │ ├── LICENSE │ │ ├── MEX │ │ ├── compilePyrTools.m │ │ ├── convolve.c │ │ ├── convolve.h │ │ ├── corrDn.c │ │ ├── corrDn.mexa64 │ │ ├── corrDn.mexglx │ │ ├── corrDn.mexmac │ │ ├── corrDn.mexmaci64 │ │ ├── corrDn.mexw32 │ │ ├── edges-orig.c │ │ ├── edges.c │ │ ├── histo.c │ │ ├── histo.mexa64 │ │ ├── histo.mexglx │ │ ├── histo.mexmac │ │ ├── histo.mexmaci64 │ │ ├── histo.mexw32 │ │ ├── innerProd.c │ │ ├── pointOp.c │ │ ├── pointOp.mexa64 │ │ ├── pointOp.mexglx │ │ ├── pointOp.mexmac │ │ ├── pointOp.mexmaci64 │ │ ├── pointOp.mexw32 │ │ ├── range2.c │ │ ├── range2.mexa64 │ │ ├── range2.mexglx │ │ ├── range2.mexmac │ │ ├── range2.mexmaci64 │ │ ├── range2.mexw32 │ │ ├── upConv.c │ │ ├── upConv.mexa64 │ │ ├── upConv.mexglx │ │ ├── upConv.mexmac │ │ ├── upConv.mexmaci64 │ │ ├── upConv.mexw32 │ │ └── wrap.c │ │ ├── README │ │ ├── TUTORIALS │ │ ├── HTML │ │ │ ├── lcv.css │ │ │ ├── matlabPyrTools.png │ │ │ ├── matlabPyrTools_0.1.png │ │ │ ├── matlabPyrTools_0.2.png │ │ │ ├── matlabPyrTools_0.3.png │ │ │ ├── matlabPyrTools_01.png │ │ │ ├── matlabPyrTools_02.png │ │ │ ├── matlabPyrTools_03.png │ │ │ ├── matlabPyrTools_04.png │ │ │ ├── matlabPyrTools_05.png │ │ │ ├── matlabPyrTools_06.png │ │ │ ├── matlabPyrTools_07.png │ │ │ ├── matlabPyrTools_08.png │ │ │ ├── matlabPyrTools_09.png │ │ │ ├── matlabPyrTools_10.png │ │ │ ├── matlabPyrTools_11.png │ │ │ ├── matlabPyrTools_12.png │ │ │ ├── matlabPyrTools_13.png │ │ │ ├── matlabPyrTools_14.png │ │ │ ├── matlabPyrTools_15.png │ │ │ ├── matlabPyrTools_16.png │ │ │ ├── matlabPyrTools_17.png │ │ │ ├── matlabPyrTools_18.png │ │ │ ├── matlabPyrTools_19.png │ │ │ ├── matlabPyrTools_20.png │ │ │ ├── matlabPyrTools_21.png │ │ │ ├── matlabPyrTools_22.png │ │ │ ├── matlabPyrTools_23.png │ │ │ ├── matlabPyrTools_24.png │ │ │ ├── pyramids.png │ │ │ ├── pyramids_01.png │ │ │ ├── pyramids_02.png │ │ │ ├── pyramids_03.png │ │ │ ├── pyramids_04.png │ │ │ ├── pyramids_05.png │ │ │ ├── pyramids_06.png │ │ │ ├── pyramids_07.png │ │ │ ├── pyramids_08.png │ │ │ ├── pyramids_09.png │ │ │ ├── pyramids_10.png │ │ │ ├── pyramids_11.5.png │ │ │ ├── pyramids_11.png │ │ │ ├── pyramids_12.png │ │ │ ├── pyramids_13.png │ │ │ ├── pyramids_14.png │ │ │ ├── pyramids_15.png │ │ │ ├── pyramids_16.png │ │ │ ├── pyramids_17.png │ │ │ ├── pyramids_18.png │ │ │ ├── pyramids_19.png │ │ │ ├── pyramids_20.png │ │ │ ├── pyramids_21.png │ │ │ ├── pyramids_22.png │ │ │ ├── pyramids_23.png │ │ │ ├── pyramids_24.png │ │ │ ├── pyramids_25.png │ │ │ ├── pyramids_26.png │ │ │ ├── pyramids_27.png │ │ │ ├── pyramids_28.5.png │ │ │ ├── pyramids_28.png │ │ │ ├── pyramids_29.png │ │ │ ├── pyramids_30.png │ │ │ ├── pyramids_31.png │ │ │ ├── pyramids_32.png │ │ │ ├── pyramids_33.png │ │ │ ├── pyramids_34.png │ │ │ ├── pyramids_35.png │ │ │ ├── pyramids_36.5.png │ │ │ ├── pyramids_36.png │ │ │ ├── pyramids_37.3.png │ │ │ ├── pyramids_37.6.png │ │ │ ├── pyramids_37.png │ │ │ ├── pyramids_38.5.png │ │ │ ├── pyramids_38.png │ │ │ ├── pyramids_39.5.png │ │ │ ├── pyramids_39.png │ │ │ ├── pyramids_40.png │ │ │ ├── pyramids_41.png │ │ │ ├── pyramids_42.png │ │ │ ├── pyramids_43.png │ │ │ ├── pyramids_44.png │ │ │ ├── pyramids_45.png │ │ │ ├── pyramids_46.png │ │ │ ├── pyramids_47.png │ │ │ ├── pyramids_48.png │ │ │ ├── pyramids_49.png │ │ │ ├── pyramids_5.5.png │ │ │ ├── pyramids_50.png │ │ │ ├── pyramids_51.png │ │ │ ├── pyramids_52.5.png │ │ │ ├── pyramids_52.png │ │ │ ├── pyramids_53.png │ │ │ ├── pyramids_54.png │ │ │ ├── pyramids_55.png │ │ │ ├── pyramids_56.png │ │ │ ├── pyramids_57.png │ │ │ ├── pyramids_58.png │ │ │ ├── pyramids_59.png │ │ │ ├── pyramids_60.png │ │ │ ├── pyramids_61.png │ │ │ ├── pyramids_62.png │ │ │ ├── pyramids_63.png │ │ │ ├── pyramids_64.png │ │ │ ├── pyramids_65.png │ │ │ ├── pyramids_66.png │ │ │ ├── pyramids_67.png │ │ │ ├── pyramids_68.png │ │ │ ├── pyramids_69.png │ │ │ ├── pyramids_70.png │ │ │ ├── pyramids_71.png │ │ │ ├── pyramids_72.png │ │ │ ├── pyramids_73.png │ │ │ ├── pyramids_74.png │ │ │ └── pyramids_75.png │ │ ├── README │ │ ├── matlabPyrTools.html │ │ ├── matlabPyrTools.m │ │ ├── pyramids.html │ │ └── pyramids.m │ │ ├── binomialFilter.m │ │ ├── blur.m │ │ ├── blurDn.m │ │ ├── buildGpyr.m │ │ ├── buildLpyr.m │ │ ├── buildSCFpyr.m │ │ ├── buildSCFpyrLevs.m │ │ ├── buildSFpyr.m │ │ ├── buildSFpyrLevs.m │ │ ├── buildSpyr.m │ │ ├── buildSpyrLevs.m │ │ ├── buildWpyr.m │ │ ├── cconv2.m │ │ ├── clip.m │ │ ├── corrDn.m │ │ ├── einstein.pgm │ │ ├── entropy2.m │ │ ├── factorial.m │ │ ├── feynman.pgm │ │ ├── histo.m │ │ ├── histoMatch.asv │ │ ├── histoMatch.m │ │ ├── imGradient.m │ │ ├── imStats.m │ │ ├── innerProd.m │ │ ├── kurt2.m │ │ ├── lplot.m │ │ ├── lpyrHt.m │ │ ├── maxPyrHt.m │ │ ├── mean2.m │ │ ├── mkAngle.m │ │ ├── mkAngularSine.m │ │ ├── mkDisc.m │ │ ├── mkFract.m │ │ ├── mkGaussian.m │ │ ├── mkImpulse.m │ │ ├── mkR.m │ │ ├── mkRamp.m │ │ ├── mkSine.m │ │ ├── mkSquare.m │ │ ├── mkZonePlate.m │ │ ├── modulateFlip.m │ │ ├── namedFilter.m │ │ ├── nextFig.m │ │ ├── pgmRead.m │ │ ├── pgmWrite.m │ │ ├── pixelAxes.m │ │ ├── pointOp.m │ │ ├── pwd2path.m │ │ ├── pyrBand.m │ │ ├── pyrBandIndices.m │ │ ├── pyrLow.m │ │ ├── range2.m │ │ ├── rconv2.m │ │ ├── rcosFn.m │ │ ├── reconLpyr.m │ │ ├── reconSCFpyr.m │ │ ├── reconSFpyr.m │ │ ├── reconSFpyrLevs.m │ │ ├── reconSpyr.m │ │ ├── reconSpyrLevs.m │ │ ├── reconWpyr.m │ │ ├── setPyrBand.m │ │ ├── shift.m │ │ ├── showIm.m │ │ ├── showLpyr.m │ │ ├── showSpyr.m │ │ ├── showWpyr.m │ │ ├── skew2.m │ │ ├── sp0Filters.m │ │ ├── sp1Filters.m │ │ ├── sp3Filters.m │ │ ├── sp5Filters.m │ │ ├── spyrBand.m │ │ ├── spyrHigh.m │ │ ├── spyrHt.m │ │ ├── spyrLev.m │ │ ├── spyrNumBands.m │ │ ├── steer.m │ │ ├── steer2HarmMtx.m │ │ ├── subMtx.m │ │ ├── upBlur.m │ │ ├── upConv.m │ │ ├── var2.m │ │ ├── vectify.m │ │ ├── wpyrBand.m │ │ ├── wpyrHt.m │ │ ├── wpyrLev.m │ │ └── zconv2.m ├── stylegan │ ├── __init__.py │ ├── generate_dataset.py │ ├── scripts │ │ ├── generate_dataset.sh │ │ └── generate_dataset_high_res.sh │ └── stylegan2-ada-pytorch │ │ ├── .github │ │ └── ISSUE_TEMPLATE │ │ │ └── bug_report.md │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── calc_metrics.py │ │ ├── dataset_tool.py │ │ ├── dnnlib │ │ ├── __init__.py │ │ ├── tflib │ │ │ ├── __init__.py │ │ │ ├── autosummary.py │ │ │ ├── custom_ops.py │ │ │ ├── network.py │ │ │ ├── ops │ │ │ │ ├── __init__.py │ │ │ │ ├── fused_bias_act.cu │ │ │ │ ├── fused_bias_act.py │ │ │ │ ├── upfirdn_2d.cu │ │ │ │ └── upfirdn_2d.py │ │ │ ├── optimizer.py │ │ │ └── tfutil.py │ │ └── util.py │ │ ├── dnnlib_from_tf │ │ ├── __init__.py │ │ ├── submission │ │ │ ├── __init__.py │ │ │ ├── internal │ │ │ │ ├── __init__.py │ │ │ │ └── local.py │ │ │ ├── run_context.py │ │ │ └── submit.py │ │ ├── tflib │ │ │ ├── __init__.py │ │ │ ├── autosummary.py │ │ │ ├── custom_ops.py │ │ │ ├── network.py │ │ │ ├── ops │ │ │ │ ├── __init__.py │ │ │ │ ├── fused_bias_act.cu │ │ │ │ ├── fused_bias_act.py │ │ │ │ ├── upfirdn_2d.cu │ │ │ │ └── upfirdn_2d.py │ │ │ ├── optimizer.py │ │ │ └── tfutil.py │ │ └── util.py │ │ ├── dnnlib_old │ │ ├── __init__.py │ │ ├── tflib │ │ │ ├── __init__.py │ │ │ ├── autosummary.py │ │ │ ├── custom_ops.py │ │ │ ├── network.py │ │ │ ├── ops │ │ │ │ ├── __init__.py │ │ │ │ ├── fused_bias_act.cu │ │ │ │ ├── fused_bias_act.py │ │ │ │ ├── upfirdn_2d.cu │ │ │ │ └── upfirdn_2d.py │ │ │ ├── optimizer.py │ │ │ └── tfutil.py │ │ └── util.py │ │ ├── docker_run.sh │ │ ├── docs │ │ ├── dataset-tool-help.txt │ │ ├── license.html │ │ ├── stylegan2-ada-teaser-1024x252.png │ │ ├── stylegan2-ada-training-curves.png │ │ └── train-help.txt │ │ ├── experiments │ │ └── train_stylegan2.sh │ │ ├── generate.py │ │ ├── legacy.py │ │ ├── metrics │ │ ├── __init__.py │ │ ├── frechet_inception_distance.py │ │ ├── inception_score.py │ │ ├── kernel_inception_distance.py │ │ ├── metric_main.py │ │ ├── metric_utils.py │ │ ├── perceptual_path_length.py │ │ └── precision_recall.py │ │ ├── projector.py │ │ ├── slurm_sc │ │ ├── stylegan_imagenet.slurm │ │ └── test.slurm │ │ ├── style_mixing.py │ │ ├── torch_utils │ │ ├── __init__.py │ │ ├── custom_ops.py │ │ ├── misc.py │ │ ├── ops │ │ │ ├── __init__.py │ │ │ ├── bias_act.cpp │ │ │ ├── bias_act.cu │ │ │ ├── bias_act.h │ │ │ ├── bias_act.py │ │ │ ├── conv2d_gradfix.py │ │ │ ├── conv2d_resample.py │ │ │ ├── fma.py │ │ │ ├── grid_sample_gradfix.py │ │ │ ├── upfirdn2d.cpp │ │ │ ├── upfirdn2d.cu │ │ │ ├── upfirdn2d.h │ │ │ └── upfirdn2d.py │ │ ├── persistence.py │ │ └── training_stats.py │ │ ├── train.py │ │ └── training │ │ ├── __init__.py │ │ ├── augment.py │ │ ├── dataset.py │ │ ├── loss.py │ │ ├── network_randomized.py │ │ ├── network_randomized_norgb.py │ │ ├── network_randomized_v2.py │ │ ├── network_randomized_v3.py │ │ ├── network_shuffling.py │ │ ├── networks.py │ │ ├── networks2.py │ │ └── training_loop.py └── utils_generation.py ├── moco ├── LICENSE ├── README.md ├── __init__.py ├── detection │ ├── README.md │ ├── configs │ │ ├── Base-RCNN-C4-BN.yaml │ │ ├── coco_R_50_C4_2x.yaml │ │ ├── coco_R_50_C4_2x_moco.yaml │ │ ├── pascal_voc_R_50_C4_24k.yaml │ │ └── pascal_voc_R_50_C4_24k_moco.yaml │ ├── convert-pretrain-to-detectron2.py │ └── train_net.py ├── main_lincls.py ├── main_moco.py └── moco │ ├── __init__.py │ ├── builder.py │ └── loader.py ├── requirements.txt └── scripts ├── download_datasets ├── download_large_scale_datasets.sh └── download_small_scale_datasets.sh ├── download_pretrained_models ├── download_large_scale_encoders.sh └── download_small_scale_encoders.sh ├── generate_datasets └── generate_imagenet100.sh ├── generate_vtab_datasets ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── __init__.py ├── docs │ ├── 404.html │ ├── Gemfile │ ├── Gemfile.lock │ ├── _config.yml │ ├── _includes │ │ └── abstract.md │ ├── benchmark.html │ ├── benchmark_data.css │ ├── benchmark_data.js │ └── index.md ├── download_and_dump_all_vtab_datasets.sh ├── dump_datasets.py ├── experiments │ ├── dump_all_datasets.sh │ ├── missing_datasets │ │ ├── test_default_model_missing_datasets_0.sh │ │ └── test_model_small_lr.sh │ ├── pretrained_resnet_all.sh │ ├── pretrained_smallalexnet.sh │ ├── pretrained_vgg.sh │ ├── resnet_moco_pretrained.sh │ ├── resnet_random_all.sh │ ├── test_best_tfhub_model.sh │ ├── test_model.sh │ ├── test_resnet_moco.sh │ └── test_tfhub_model.sh ├── generate_subset_datasets.py ├── modified_builders │ └── sun397_ours.py ├── port_model │ ├── __init__.py │ ├── dog.jpeg │ ├── imagenet_id_to_name │ ├── port_model.py │ ├── port_utils.py │ └── test_supervised_ported_model.py ├── scripts │ └── run_all_tasks.sh ├── setup.py ├── task_adaptation │ ├── __init__.py │ ├── adapt_and_eval.py │ ├── data_loader.py │ ├── data_loader_test.py │ ├── loop.py │ ├── loop_test.py │ ├── model.py │ ├── model_test.py │ ├── registry.py │ ├── registry_test.py │ ├── test_utils.py │ ├── trainer.py │ └── trainer_test.py └── tests │ ├── count_number_of_dumped_images.py │ ├── split_rsics.py │ ├── test_same_parameters.py │ └── test_sun397.py ├── train_align_uniform ├── cat_linear_eval_imagenet100.sh ├── linear_eval_imagenet100.sh ├── linear_eval_vtab.sh └── main.sh └── train_moco └── train_main_and_linear_moco.sh /.gitignore: -------------------------------------------------------------------------------- 1 | data 2 | encoders 3 | lincls_imagenet 4 | .idea 5 | scripts/our* 6 | __pycache__ 7 | -------------------------------------------------------------------------------- /align_uniform/__init__.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def align_loss(x, y, alpha=2): 5 | return (x - y).norm(p=2, dim=1).pow(alpha).mean() 6 | 7 | 8 | def uniform_loss(x, t=2): 9 | return torch.pdist(x, p=2).pow(2).mul(-t).exp().mean().log() 10 | 11 | 12 | __all__ = ['align_loss', 'uniform_loss'] 13 | -------------------------------------------------------------------------------- /align_uniform/util.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class AverageMeter(object): 5 | r""" 6 | Computes and stores the average and current value. 7 | Adapted from 8 | https://github.com/pytorch/examples/blob/ec10eee2d55379f0b9c87f4b36fcf8d0723f45fc/imagenet/main.py#L359-L380 9 | """ 10 | def __init__(self, name=None, fmt='.6f'): 11 | fmtstr = f'{{val:{fmt}}} ({{avg:{fmt}}})' 12 | if name is not None: 13 | fmtstr = name + ' ' + fmtstr 14 | self.fmtstr = fmtstr 15 | self.reset() 16 | 17 | def reset(self): 18 | self.val = 0 19 | self.sum = 0 20 | self.count = 0 21 | 22 | def update(self, val, n=1): 23 | self.val = val 24 | self.sum += val * n 25 | self.count += n 26 | 27 | @property 28 | def avg(self): 29 | avg = self.sum / self.count 30 | if isinstance(avg, torch.Tensor): 31 | avg = avg.item() 32 | return avg 33 | 34 | def __str__(self): 35 | val = self.val 36 | if isinstance(val, torch.Tensor): 37 | val = val.item() 38 | return self.fmtstr.format(val=val, avg=self.avg) 39 | 40 | 41 | class TwoAugUnsupervisedDataset(torch.utils.data.Dataset): 42 | r"""Returns two augmentation and no labels.""" 43 | def __init__(self, dataset, transform): 44 | self.dataset = dataset 45 | self.transform = transform 46 | 47 | def __getitem__(self, index): 48 | image, _ = self.dataset[index] 49 | return self.transform(image), self.transform(image) 50 | 51 | def __len__(self): 52 | return len(self.dataset) 53 | -------------------------------------------------------------------------------- /generate_datasets/dead_leaves/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/dead_leaves/__init__.py -------------------------------------------------------------------------------- /generate_datasets/feature_visualizations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/feature_visualizations/__init__.py -------------------------------------------------------------------------------- /generate_datasets/feature_visualizations/vis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/feature_visualizations/vis/__init__.py -------------------------------------------------------------------------------- /generate_datasets/feature_visualizations/vis/grad_ascent/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/feature_visualizations/vis/grad_ascent/__init__.py -------------------------------------------------------------------------------- /generate_datasets/readme_assets/all_models.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/readme_assets/all_models.jpg -------------------------------------------------------------------------------- /generate_datasets/requirements.txt: -------------------------------------------------------------------------------- 1 | pyrtools 2 | lucent -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/__init__.py -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/generate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | matlab -nodisplay -r "generate_datasets_big;exit" -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/generate_datasets.m: -------------------------------------------------------------------------------- 1 | addpath ('matlabPyrTools') 2 | 3 | N_samples_256 = 1300000; 4 | N_samples_128 = 105000; 5 | 6 | dataset_dir = 'generated_datasets/matlab_statistical_models'; 7 | 8 | % for multimachine, we randomize list so that each machine processes at 9 | % random, we check file not written before generating and before saving 10 | sample_list_256 = randomize_list(0:N_samples_256 - 1); 11 | sample_list_128 = randomize_list(0:N_samples_128 - 1); 12 | 13 | % impose_spectrum, impose_wmm, impose_color_model, jpg 14 | 15 | % dataset 1 Only spectrum 16 | image_model.generate_projection_dataset(sample_list_256, 256, dataset_dir, true, false, false, true) 17 | image_model.generate_projection_dataset(sample_list_128, 128, dataset_dir, true, false, false, true) 18 | 19 | % dataset 2 Only Wmm 20 | image_model.generate_projection_dataset(sample_list_256, 256, dataset_dir, false, true, false, true) 21 | image_model.generate_projection_dataset(sample_list_128, 128, dataset_dir, false, true, false, true) 22 | 23 | % dataset 3 Only spectrum + Color 24 | image_model.generate_projection_dataset(sample_list_256, 256, dataset_dir, true, false, true, true) 25 | image_model.generate_projection_dataset(sample_list_128, 128, dataset_dir, true, false, true, true) 26 | 27 | % dataset 4 Color + spectrum + wmm 28 | image_model.generate_projection_dataset(sample_list_256, 256, dataset_dir, true, true, true, true) 29 | image_model.generate_projection_dataset(sample_list_128, 128, dataset_dir, true, true, true, true) 30 | 31 | 32 | function randomized_list = randomize_list(v) 33 | d = datetime('now'); 34 | seed = mod(posixtime(d) * 1000000, 1000000); 35 | rand('seed', seed); randn('seed', seed); 36 | randomized_list = v(randperm(length(v))); 37 | end -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 LabForComputationalVision 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/compilePyrTools.m: -------------------------------------------------------------------------------- 1 | % This is a script file for compiling the mex versions of the Steerable 2 | % Pyramid Tools. 3 | % 4 | % Usage:>> compilePyrTools 5 | % 6 | % Tested for gcc and lcc. 7 | % 8 | % Rob Young, 9/08 9 | 10 | mex upConv.c convolve.c wrap.c edges.c 11 | mex corrDn.c convolve.c wrap.c edges.c 12 | mex histo.c 13 | %mex innerProd.c 14 | mex pointOp.c 15 | mex range2.c 16 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/convolve.h: -------------------------------------------------------------------------------- 1 | /* 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3 | ;;; File: convolve.h 4 | ;;; Author: Simoncelli 5 | ;;; Description: Header file for convolve.c 6 | ;;; Creation Date: 7 | ;;; ---------------------------------------------------------------- 8 | ;;; Object-Based Vision and Image Understanding System (OBVIUS), 9 | ;;; Copyright 1988, Vision Science Group, Media Laboratory, 10 | ;;; Massachusetts Institute of Technology. 11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #define ABS(x) (((x)>=0) ? (x) : (-(x))) 18 | #define ROOT2 1.4142135623730951 19 | #define REDUCE 0 20 | #define EXPAND 1 21 | #define IS == 22 | #define ISNT != 23 | #define AND && 24 | #define OR || 25 | 26 | typedef int (*fptr)(); 27 | 28 | typedef struct 29 | { 30 | char *name; 31 | fptr func; 32 | } EDGE_HANDLER; 33 | 34 | typedef double image_type; 35 | 36 | fptr edge_function(char *edges); 37 | int internal_reduce(image_type *image, int x_idim, int y_idim, 38 | image_type *filt, image_type *temp, int x_fdim, int y_fdim, 39 | int x_start, int x_step, int x_stop, 40 | int y_start, int y_step, int y_stop, 41 | image_type *result, char *edges); 42 | int internal_expand(image_type *image, 43 | image_type *filt, image_type *temp, int x_fdim, int y_fdim, 44 | int x_start, int x_step, int x_stop, 45 | int y_start, int y_step, int y_stop, 46 | image_type *result, int x_rdim, int y_rdim, char *edges); 47 | int internal_wrap_reduce(image_type *image, int x_idim, int y_idim, 48 | image_type *filt, int x_fdim, int y_fdim, 49 | int x_start, int x_step, int x_stop, 50 | int y_start, int y_step, int y_stop, 51 | image_type *result); 52 | int internal_wrap_expand(image_type *image, image_type *filt, int x_fdim, int y_fdim, 53 | int x_start, int x_step, int x_stop, 54 | int y_start, int y_step, int y_stop, 55 | image_type *result, int x_rdim, int y_rdim); 56 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexa64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexglx -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexmac -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexmaci64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/corrDn.mexw32 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexa64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexglx -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexmac -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexmaci64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/histo.mexw32 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/innerProd.c: -------------------------------------------------------------------------------- 1 | /* 2 | RES = innerProd(MAT); 3 | Computes mat'*mat 4 | Odelia Schwartz, 8/97. 5 | */ 6 | 7 | #define V4_COMPAT 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | void mexFunction(int nlhs, /* Num return vals on lhs */ 17 | mxArray *plhs[], /* Matrices on lhs */ 18 | int nrhs, /* Num args on rhs */ 19 | const mxArray *prhs[] /* Matrices on rhs */ 20 | ) 21 | { 22 | register double *res, *mat, tmp; 23 | register int len, wid, i, k, j, jlen, ilen, imat, jmat; 24 | mxArray *arg; 25 | 26 | /* get matrix input argument */ 27 | /* should be matrix in which num rows >= num columns */ 28 | arg=prhs[0]; 29 | mat= mxGetPr(arg); 30 | len = (int) mxGetM(arg); 31 | wid = (int) mxGetN(arg); 32 | if ( wid > len ) 33 | printf("innerProd: Warning: width %d is greater than length %d.\n",wid,len); 34 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(wid,wid,mxREAL); 35 | if (plhs[0] == NULL) 36 | mexErrMsgTxt(sprintf("Error allocating %dx%d result matrix",wid,wid)); 37 | res = mxGetPr(plhs[0]); 38 | 39 | for(i=0, ilen=0; i>> See range2.m for documentation <<< 4 | EPS, 3/97. 5 | */ 6 | 7 | #define V4_COMPAT 8 | #include /* Matlab matrices */ 9 | #include 10 | 11 | #include /* NULL */ 12 | 13 | #define notDblMtx(it) (!mxIsNumeric(it) || !mxIsDouble(it) || mxIsSparse(it) || mxIsComplex(it)) 14 | 15 | void mexFunction(int nlhs, /* Num return vals on lhs */ 16 | mxArray *plhs[], /* Matrices on lhs */ 17 | int nrhs, /* Num args on rhs */ 18 | const mxArray *prhs[] /* Matrices on rhs */ 19 | ) 20 | { 21 | register double temp, mn, mx; 22 | register double *mtx; 23 | register int i, size; 24 | const mxArray *arg; 25 | 26 | if (nrhs != 1) mexErrMsgTxt("requires 1 argument."); 27 | 28 | /* ARG 1: MATRIX */ 29 | arg = prhs[0]; 30 | if notDblMtx(arg) mexErrMsgTxt("MTX arg must be a real non-sparse matrix."); 31 | mtx = mxGetPr(arg); 32 | size = (int) mxGetM(arg) * mxGetN(arg); 33 | 34 | /* FIND min, max values of MTX */ 35 | mn = *mtx; mx = *mtx; 36 | for (i=1; i mx) 42 | mx = temp; 43 | } 44 | 45 | plhs[0] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); 46 | if (plhs[0] == NULL) mexErrMsgTxt("Error allocating result matrix"); 47 | plhs[1] = (mxArray *) mxCreateDoubleMatrix(1,1,mxREAL); 48 | if (plhs[1] == NULL) mexErrMsgTxt("Error allocating result matrix"); 49 | mtx = mxGetPr(plhs[0]); 50 | mtx[0] = mn; 51 | mtx = mxGetPr(plhs[1]); 52 | mtx[0] = mx; 53 | 54 | return; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexa64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexglx -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexmac -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexmaci64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/range2.mexw32 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexa64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexglx -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexmac -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexmaci64 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/MEX/upConv.mexw32 -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/lcv.css: -------------------------------------------------------------------------------- 1 | BODY {margin-left:20; margin-top:5; margin-width:15; margin-height:5; font-family:helvetica,arial,sans-serif} 2 | 3 | P.titledlist {margin-left: 2.4em; text-indent: -2.4em; line-height: 1.3; 4 | margin-top: 1.8ex; margin-bottom: 1.8ex;} 5 | 6 | P.people { margin-top: 0ex; margin-bottom: 0.6ex; margin-left: 12px; 7 | text-indent: -12px; } 8 | 9 | P.research {margin-top: 1ex; margin-bottom: 1ex;} 10 | 11 | UL.compact {list-style-image:none; list-style: inside disc } 12 | 13 | LI.software {margin-top: 1ex; margin-bottom: 0ex;} 14 | 15 | a:link {text-decoration:none;} 16 | 17 | a:visited {text-decoration:none;} 18 | 19 | a:hover {color:blue; text-decoration:underline;} 20 | 21 | a span {display:none;} 22 | 23 | a:hover span {display:block; position:fixed; left:150px; padding:5px; background: #f0f0f0; border: 1px dotted #c0c0c0; opacity: 1;} 24 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_0.1.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_0.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_0.2.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_0.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_0.3.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_01.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_02.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_03.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_04.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_05.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_06.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_07.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_08.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_09.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_10.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_11.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_12.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_13.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_14.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_15.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_16.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_17.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_18.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_19.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_20.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_21.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_22.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_23.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/matlabPyrTools_24.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_01.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_02.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_03.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_04.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_05.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_06.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_07.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_08.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_09.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_10.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_11.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_11.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_11.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_12.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_13.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_14.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_15.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_16.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_17.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_18.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_19.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_20.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_21.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_22.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_23.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_24.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_25.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_26.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_27.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_28.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_28.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_28.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_29.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_30.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_31.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_32.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_33.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_34.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_35.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_36.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_36.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_36.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_37.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_37.3.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_37.6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_37.6.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_37.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_38.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_38.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_38.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_39.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_39.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_39.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_40.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_41.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_42.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_43.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_44.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_45.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_46.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_47.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_48.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_49.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_5.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_5.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_50.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_51.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_52.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_52.5.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_52.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_53.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_54.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_55.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_56.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_57.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_58.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_59.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_60.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_61.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_62.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_63.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_63.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_64.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_65.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_65.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_66.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_67.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_67.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_68.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_68.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_69.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_69.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_70.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_71.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_72.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_73.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_73.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_74.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_74.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/HTML/pyramids_75.png -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/TUTORIALS/README: -------------------------------------------------------------------------------- 1 | 2 | This directory contains some Matlab script files that serve to give 3 | example usage of this code, and also to explain some of the 4 | representations and algorithms. 5 | 6 | The files are NOT meant to be executed from the MatLab prompt (like many 7 | of the MatLab demos). You should instead read through the comments, 8 | executing the subsequent pieces of code. This gives you a chance to 9 | explore as you go... 10 | 11 | matlabPyrTools.m - Example usage of the code in the distribution. 12 | 13 | pyramids.m - An introduction to multi-scale pyramid representations, 14 | covering Laplacian, QMF/Wavelet, and Steerable pyramids. The 15 | file assumes a knowledge of linear systems, matrix algebra, 16 | and 2D Fourier transforms. 17 | 18 | matlabPyrTools.html - Same as matlabPyrTools.m, but formatted in html that 19 | shows sample output. 20 | 21 | pyramids.html - Same as pyramids.m, but formatted in html that shows sample 22 | output. 23 | 24 | more to come.... 25 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/binomialFilter.m: -------------------------------------------------------------------------------- 1 | % KERNEL = binomialFilter(size) 2 | % 3 | % Returns a vector of binomial coefficients of order (size-1) . 4 | 5 | % Eero Simoncelli, 2/97. 6 | 7 | function [kernel] = binomialFilter(sz) 8 | 9 | if (sz < 2) 10 | error('size argument must be larger than 1'); 11 | end 12 | 13 | kernel = [0.5 0.5]'; 14 | 15 | for n=1:sz-2 16 | kernel = conv([0.5 0.5]', kernel); 17 | end 18 | 19 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/blur.m: -------------------------------------------------------------------------------- 1 | % RES = blur(IM, LEVELS, FILT) 2 | % 3 | % Blur an image, by filtering and downsampling LEVELS times 4 | % (default=1), followed by upsampling and filtering LEVELS times. The 5 | % blurring is done with filter kernel specified by FILT (default = 6 | % 'binom5'), which can be a string (to be passed to namedFilter), a 7 | % vector (applied separably as a 1D convolution kernel in X and Y), or 8 | % a matrix (applied as a 2D convolution kernel). The downsampling is 9 | % always by 2 in each direction. 10 | 11 | % Eero Simoncelli, 3/04. 12 | 13 | function res = blur(im, nlevs, filt) 14 | 15 | %------------------------------------------------------------ 16 | %% OPTIONAL ARGS: 17 | 18 | if (exist('nlevs') ~= 1) 19 | nlevs = 1; 20 | end 21 | 22 | if (exist('filt') ~= 1) 23 | filt = 'binom5'; 24 | end 25 | 26 | %------------------------------------------------------------ 27 | 28 | if isstr(filt) 29 | filt = namedFilter(filt); 30 | end 31 | 32 | filt = filt/sum(filt(:)); 33 | 34 | if nlevs > 0 35 | if (any(size(im)==1)) 36 | if (~any(size(filt)==1)) 37 | error('Cant apply 2D filter to 1D signal'); 38 | end 39 | if (size(im,2)==1) 40 | filt = filt(:); 41 | else 42 | filt = filt(:)'; 43 | end 44 | 45 | in = corrDn(im,filt,'reflect1',(size(im)~=1)+1); 46 | out = blur(in, nlevs-1, filt); 47 | res = upConv(out, filt, 'reflect1', (size(im)~=1)+1, [1 1], size(im)); 48 | 49 | elseif (any(size(filt)==1)) 50 | filt = filt(:); 51 | 52 | in = corrDn(im,filt,'reflect1',[2 1]); 53 | in = corrDn(in,filt','reflect1',[1 2]); 54 | out = blur(in, nlevs-1, filt); 55 | res = upConv(out, filt', 'reflect1', [1 2], [1 1], [size(out,1),size(im,2)]); 56 | res = upConv(res, filt, 'reflect1', [2 1], [1 1], size(im)); 57 | 58 | else 59 | 60 | in = corrDn(im,filt,'reflect1',[2 2]); 61 | out = blur(in, nlevs-1, filt); 62 | res = upConv(out, filt, 'reflect1', [2 2], [1 1], size(im)); 63 | end 64 | else 65 | res = im; 66 | end 67 | 68 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/blurDn.m: -------------------------------------------------------------------------------- 1 | % RES = blurDn(IM, LEVELS, FILT) 2 | % 3 | % Blur and downsample an image. The blurring is done with filter 4 | % kernel specified by FILT (default = 'binom5'), which can be a string 5 | % (to be passed to namedFilter), a vector (applied separably as a 1D 6 | % convolution kernel in X and Y), or a matrix (applied as a 2D 7 | % convolution kernel). The downsampling is always by 2 in each 8 | % direction. 9 | % 10 | % The procedure is applied recursively LEVELS times (default=1). 11 | 12 | % Eero Simoncelli, 3/97. 13 | 14 | function res = blurDn(im, nlevs, filt) 15 | 16 | %------------------------------------------------------------ 17 | %% OPTIONAL ARGS: 18 | 19 | if (exist('nlevs') ~= 1) 20 | nlevs = 1; 21 | end 22 | 23 | if (exist('filt') ~= 1) 24 | filt = 'binom5'; 25 | end 26 | 27 | %------------------------------------------------------------ 28 | 29 | if isstr(filt) 30 | filt = namedFilter(filt); 31 | end 32 | 33 | filt = filt/sum(filt(:)); 34 | 35 | if nlevs > 1 36 | im = blurDn(im,nlevs-1,filt); 37 | end 38 | 39 | if (nlevs >= 1) 40 | if (any(size(im)==1)) 41 | if (~any(size(filt)==1)) 42 | error('Cant apply 2D filter to 1D signal'); 43 | end 44 | if (size(im,2)==1) 45 | filt = filt(:); 46 | else 47 | filt = filt(:)'; 48 | end 49 | res = corrDn(im,filt,'reflect1',(size(im)~=1)+1); 50 | elseif (any(size(filt)==1)) 51 | filt = filt(:); 52 | res = corrDn(im,filt,'reflect1',[2 1]); 53 | res = corrDn(res,filt','reflect1',[1 2]); 54 | else 55 | res = corrDn(im,filt,'reflect1',[2 2]); 56 | end 57 | else 58 | res = im; 59 | end 60 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/buildGpyr.m: -------------------------------------------------------------------------------- 1 | % [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES) 2 | % 3 | % Construct a Gaussian pyramid on matrix IM. 4 | % 5 | % HEIGHT (optional) specifies the number of pyramid levels to build. Default 6 | % is 1+maxPyrHt(size(IM),size(FILT)). 7 | % You can also specify 'auto' to use this value. 8 | % 9 | % FILT (optional) can be a string naming a standard filter (see 10 | % namedFilter), or a vector which will be used for (separable) 11 | % convolution. Default = 'binom5'. EDGES specifies edge-handling, and 12 | % defaults to 'reflect1' (see corrDn). 13 | % 14 | % PYR is a vector containing the N pyramid subbands, ordered from fine 15 | % to coarse. INDICES is an Nx2 matrix containing the sizes of 16 | % each subband. This is compatible with the MatLab Wavelet toolbox. 17 | 18 | % Eero Simoncelli, 6/96. 19 | 20 | function [pyr,pind] = buildGpyr(im, ht, filt, edges) 21 | 22 | if (nargin < 1) 23 | error('First argument (IM) is required'); 24 | end 25 | 26 | im_sz = size(im); 27 | 28 | %------------------------------------------------------------ 29 | %% OPTIONAL ARGS: 30 | 31 | if (exist('filt') ~= 1) 32 | filt = 'binom5'; 33 | end 34 | 35 | if isstr(filt) 36 | filt = namedFilter(filt); 37 | end 38 | 39 | if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) 40 | error('FILT should be a 1D filter (i.e., a vector)'); 41 | else 42 | filt = filt(:); 43 | end 44 | 45 | max_ht = 1 + maxPyrHt(im_sz, size(filt,1)); 46 | if ( (exist('ht') ~= 1) | (ht == 'auto') ) 47 | ht = max_ht; 48 | else 49 | if (ht > max_ht) 50 | error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); 51 | end 52 | end 53 | 54 | if (exist('edges') ~= 1) 55 | edges= 'reflect1'; 56 | end 57 | 58 | %------------------------------------------------------------ 59 | 60 | if (ht <= 1) 61 | 62 | pyr = im(:); 63 | pind = im_sz; 64 | 65 | else 66 | 67 | if (im_sz(2) == 1) 68 | lo2 = corrDn(im, filt, edges, [2 1], [1 1]); 69 | elseif (im_sz(1) == 1) 70 | lo2 = corrDn(im, filt', edges, [1 2], [1 1]); 71 | else 72 | lo = corrDn(im, filt', edges, [1 2], [1 1]); 73 | lo2 = corrDn(lo, filt, edges, [2 1], [1 1]); 74 | end 75 | 76 | [npyr,nind] = buildGpyr(lo2, ht-1, filt, edges); 77 | 78 | pyr = [im(:); npyr]; 79 | pind = [im_sz; nind]; 80 | 81 | end 82 | 83 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/buildSFpyrLevs.m: -------------------------------------------------------------------------------- 1 | % [PYR, INDICES] = buildSFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) 2 | % 3 | % Recursive function for constructing levels of a steerable pyramid. This 4 | % is called by buildSFpyr, and is not usually called directly. 5 | 6 | % Eero Simoncelli, 5/97. 7 | 8 | function [pyr,pind] = buildSFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); 9 | 10 | if (ht <= 0) 11 | 12 | lo0 = ifft2(ifftshift(lodft)); 13 | pyr = real(lo0(:)); 14 | pind = size(lo0); 15 | 16 | else 17 | 18 | bands = zeros(prod(size(lodft)), nbands); 19 | bind = zeros(nbands,2); 20 | 21 | % log_rad = log_rad + 1; 22 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. 23 | 24 | lutsize = 1024; 25 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] 26 | order = nbands-1; 27 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) 28 | %% Thanks to Patrick Teo for writing this out :) 29 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); 30 | Ycosn = sqrt(const) * (cos(Xcosn)).^order; 31 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); 32 | 33 | for b = 1:nbands 34 | anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); 35 | banddft = ((-sqrt(-1))^order) .* lodft .* anglemask .* himask; 36 | band = ifft2(ifftshift(banddft)); 37 | 38 | bands(:,b) = real(band(:)); 39 | bind(b,:) = size(band); 40 | end 41 | 42 | dims = size(lodft); 43 | ctr = ceil((dims+0.5)/2); 44 | lodims = ceil((dims-0.5)/2); 45 | loctr = ceil((lodims+0.5)/2); 46 | lostart = ctr-loctr+1; 47 | loend = lostart+lodims-1; 48 | 49 | log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); 50 | angle = angle(lostart(1):loend(1),lostart(2):loend(2)); 51 | lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); 52 | YIrcos = abs(sqrt(1.0 - Yrcos.^2)); 53 | lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); 54 | 55 | lodft = lomask .* lodft; 56 | 57 | [npyr,nind] = buildSFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); 58 | 59 | pyr = [bands(:); npyr]; 60 | pind = [bind; nind]; 61 | 62 | end 63 | 64 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/buildSpyrLevs.m: -------------------------------------------------------------------------------- 1 | % [PYR, INDICES] = buildSpyrLevs(LOIM, HEIGHT, LOFILT, BFILTS, EDGES) 2 | % 3 | % Recursive function for constructing levels of a steerable pyramid. This 4 | % is called by buildSpyr, and is not usually called directly. 5 | 6 | % Eero Simoncelli, 6/96. 7 | 8 | function [pyr,pind] = buildSpyrLevs(lo0,ht,lofilt,bfilts,edges); 9 | 10 | if (ht <= 0) 11 | 12 | pyr = lo0(:); 13 | pind = size(lo0); 14 | 15 | else 16 | 17 | % Assume square filters: 18 | bfiltsz = round(sqrt(size(bfilts,1))); 19 | 20 | bands = zeros(prod(size(lo0)),size(bfilts,2)); 21 | bind = zeros(size(bfilts,2),2); 22 | 23 | for b = 1:size(bfilts,2) 24 | filt = reshape(bfilts(:,b),bfiltsz,bfiltsz); 25 | band = corrDn(lo0, filt, edges); 26 | bands(:,b) = band(:); 27 | bind(b,:) = size(band); 28 | end 29 | 30 | lo = corrDn(lo0, lofilt, edges, [2 2], [1 1]); 31 | 32 | [npyr,nind] = buildSpyrLevs(lo, ht-1, lofilt, bfilts, edges); 33 | 34 | pyr = [bands(:); npyr]; 35 | pind = [bind; nind]; 36 | 37 | end 38 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/cconv2.m: -------------------------------------------------------------------------------- 1 | % RES = CCONV2(MTX1, MTX2, CTR) 2 | % 3 | % Circular convolution of two matrices. Result will be of size of 4 | % LARGER vector. 5 | % 6 | % The origin of the smaller matrix is assumed to be its center. 7 | % For even dimensions, the origin is determined by the CTR (optional) 8 | % argument: 9 | % CTR origin 10 | % 0 DIM/2 (default) 11 | % 1 (DIM/2)+1 12 | 13 | % Eero Simoncelli, 6/96. Modified 2/97. 14 | 15 | function c = cconv2(a,b,ctr) 16 | 17 | if (exist('ctr') ~= 1) 18 | ctr = 0; 19 | end 20 | 21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) 22 | large = a; small = b; 23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) 24 | large = b; small = a; 25 | else 26 | error('one arg must be larger than the other in both dimensions!'); 27 | end 28 | 29 | ly = size(large,1); 30 | lx = size(large,2); 31 | sy = size(small,1); 32 | sx = size(small,2); 33 | 34 | %% These values are the index of the small mtx that falls on the 35 | %% border pixel of the large matrix when computing the first 36 | %% convolution response sample: 37 | sy2 = floor((sy+ctr+1)/2); 38 | sx2 = floor((sx+ctr+1)/2); 39 | 40 | % pad: 41 | clarge = [ ... 42 | large(ly-sy+sy2+1:ly,lx-sx+sx2+1:lx), large(ly-sy+sy2+1:ly,:), ... 43 | large(ly-sy+sy2+1:ly,1:sx2-1); ... 44 | large(:,lx-sx+sx2+1:lx), large, large(:,1:sx2-1); ... 45 | large(1:sy2-1,lx-sx+sx2+1:lx), ... 46 | large(1:sy2-1,:), ... 47 | large(1:sy2-1,1:sx2-1) ]; 48 | 49 | c = conv2(clarge,small,'valid'); 50 | 51 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/clip.m: -------------------------------------------------------------------------------- 1 | % [RES] = clip(IM, MINVALorRANGE, MAXVAL) 2 | % 3 | % Clip values of matrix IM to lie between minVal and maxVal: 4 | % RES = max(min(IM,MAXVAL),MINVAL) 5 | % The first argument can also specify both min and max, as a 2-vector. 6 | % If only one argument is passed, the range defaults to [0,1]. 7 | 8 | function res = clip(im, minValOrRange, maxVal) 9 | 10 | if (exist('minValOrRange') ~= 1) 11 | minVal = 0; 12 | maxVal = 1; 13 | elseif (length(minValOrRange) == 2) 14 | minVal = minValOrRange(1); 15 | maxVal = minValOrRange(2); 16 | elseif (length(minValOrRange) == 1) 17 | minVal = minValOrRange; 18 | if (exist('maxVal') ~= 1) 19 | maxVal=minVal+1; 20 | end 21 | else 22 | error('MINVAL must be a scalar or a 2-vector'); 23 | end 24 | 25 | if ( maxVal < minVal ) 26 | error('MAXVAL should be less than MINVAL'); 27 | end 28 | 29 | res = im; 30 | res(find(im < minVal)) = minVal; 31 | res(find(im > maxVal)) = maxVal; 32 | 33 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/einstein.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/einstein.pgm -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/entropy2.m: -------------------------------------------------------------------------------- 1 | % E = ENTROPY2(MTX,BINSIZE) 2 | % 3 | % Compute the first-order sample entropy of MTX. Samples of VEC are 4 | % first discretized. Optional argument BINSIZE controls the 5 | % discretization, and defaults to 256/(max(VEC)-min(VEC)). 6 | % 7 | % NOTE: This is a heavily biased estimate of entropy (it is too 8 | % small) when you don't have much data! 9 | 10 | % Eero Simoncelli, 6/96. 11 | 12 | function res = entropy2(mtx,binsize) 13 | 14 | %% Ensure it's a vector, not a matrix. 15 | vec = mtx(:); 16 | [mn,mx] = range2(vec); 17 | 18 | if (exist('binsize') == 1) 19 | nbins = max((mx-mn)/binsize, 1); 20 | else 21 | nbins = 256; 22 | end 23 | 24 | [bincount,bins] = histo(vec,nbins); 25 | 26 | %% Collect non-zero bins: 27 | H = bincount(find(bincount)); 28 | H = H/sum(H); 29 | 30 | res = -sum(H .* log2(H)); 31 | 32 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/factorial.m: -------------------------------------------------------------------------------- 1 | %% RES = factorial(NUM) 2 | % 3 | % Factorial function that works on matrices (matlab's does not). 4 | 5 | % EPS, 11/02 6 | 7 | function res = factorial(num) 8 | 9 | res = ones(size(num)); 10 | 11 | ind = find(num > 0); 12 | if ( ~isempty(ind) ) 13 | subNum = num(ind); 14 | res(ind) = subNum .* factorial(subNum-1); 15 | end 16 | 17 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/feynman.pgm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/statistical/matlab/matlabPyrTools/feynman.pgm -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/histo.m: -------------------------------------------------------------------------------- 1 | % [N,X] = histo(MTX, nbinsOrBinsize, binCenter); 2 | % 3 | % Compute a histogram of (all) elements of MTX. N contains the histogram 4 | % counts, X is a vector containg the centers of the histogram bins. 5 | % 6 | % nbinsOrBinsize (optional, default = 101) specifies either 7 | % the number of histogram bins, or the negative of the binsize. 8 | % 9 | % binCenter (optional, default = mean2(MTX)) specifies a center position 10 | % for (any one of) the histogram bins. 11 | % 12 | % How does this differ from MatLab's HIST function? This function: 13 | % - allows uniformly spaced bins only. 14 | % +/- operates on all elements of MTX, instead of columnwise. 15 | % + is much faster (approximately a factor of 80 on my machine). 16 | % + allows specification of number of bins OR binsize. Default=101 bins. 17 | % + allows (optional) specification of binCenter. 18 | 19 | % Eero Simoncelli, 3/97. 20 | 21 | function [N, X] = histo(mtx, nbins, binCtr) 22 | 23 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) 24 | 25 | fprintf(1,'WARNING: You should compile the MEX version of "histo.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); 26 | 27 | mtx = mtx(:); 28 | 29 | %------------------------------------------------------------ 30 | %% OPTIONAL ARGS: 31 | 32 | [mn,mx] = range2(mtx); 33 | 34 | if (exist('binCtr') ~= 1) 35 | binCtr = mean(mtx); 36 | end 37 | 38 | if (exist('nbins') == 1) 39 | if (nbins < 0) 40 | binSize = -nbins; 41 | else 42 | binSize = ((mx-mn)/nbins); 43 | tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); 44 | if (tmpNbins ~= nbins) 45 | warning('Using %d bins instead of requested number (%d)',tmpNbins,nbins); 46 | end 47 | end 48 | else 49 | binSize = ((mx-mn)/101); 50 | end 51 | 52 | firstBin = binCtr + binSize*round( (mn-binCtr)/binSize ); 53 | 54 | tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); 55 | 56 | bins = firstBin + binSize*[0:tmpNbins]; 57 | 58 | [N, X] = hist(mtx, bins); 59 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/histoMatch.asv: -------------------------------------------------------------------------------- 1 | % RES = histoMatch(MTX, N, X) 2 | % 3 | % Modify elements of MTX so that normalized histogram matches that 4 | % specified by vectors X and N, where N contains the histogram counts 5 | % and X the histogram bin positions (see histo). 6 | 7 | % Eero Simoncelli, 7/96. 8 | 9 | function res = histoMatch(mtx, N, X) 10 | 11 | if ( exist('histo') == 3 ) 12 | [oN, oX] = histo(mtx(:), size(X(:),1)); 13 | else 14 | [oN, oX] = hist(mtx(:), size(X(:),1)); 15 | end 16 | 17 | oStep = oX(2) - oX(1); 18 | oC = [0, cumsum(oN)]/sum(oN); 19 | oX = [oX(1)-oStep/2, oX+oStep/2]; 20 | 21 | N = N(:)'; 22 | X = X(:)'; 23 | N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic 24 | 25 | nStep = X(2) - X(1); 26 | nC = [0, cumsum(N)]/sum(N); 27 | nX = [X(1)-nStep/2, X+nStep/2]; 28 | 29 | nnX = interp1(nC, nX, oC, 'linear','extrap'); 30 | 31 | if ( exist('pointOp') == 3 ) 32 | res = pointOp(mtx, nnX, oX(1), oStep); 33 | else 34 | res = reshape(interp1(oX, nnX, mtx(:), 'linear','extrap'),size(mtx,1),size(mtx,2)); 35 | end 36 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/histoMatch.m: -------------------------------------------------------------------------------- 1 | % RES = histoMatch(MTX, N, X) 2 | % 3 | % Modify elements of MTX so that normalized histogram matches that 4 | % specified by vectors X and N, where N contains the histogram counts 5 | % and X the histogram bin positions (see histo). 6 | 7 | % Eero Simoncelli, 7/96. 8 | 9 | function res = histoMatch(mtx, N, X) 10 | 11 | if ( exist('histo') == 3 ) 12 | [oN, oX] = histo(mtx(:), size(X(:),1)); 13 | else 14 | [oN, oX] = hist(mtx(:), size(X(:),1)); 15 | end 16 | 17 | oStep = oX(2) - oX(1); 18 | oC = [0, cumsum(oN)]/sum(oN); 19 | oX = [oX(1)-oStep/2, oX+oStep/2]; 20 | 21 | N = N(:)'; 22 | X = X(:)'; 23 | N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic 24 | 25 | nStep = X(2) - X(1); 26 | nC = [0, cumsum(N)]/sum(N); 27 | nX = [X(1)-nStep/2, X+nStep/2]; 28 | 29 | nnX = interp1(nC, nX, oC, 'linear','extrap'); 30 | 31 | if ( exist('pointOp') == 3 ) 32 | res = pointOp(mtx, nnX, oX(1), oStep); 33 | else 34 | res = reshape(interp1(oX, nnX, mtx(:), 'linear','extrap'),size(mtx,1),size(mtx,2)); 35 | end 36 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/imGradient.m: -------------------------------------------------------------------------------- 1 | % [dx, dy] = imGradient(im, edges) 2 | % 3 | % Compute the gradient of the image using smooth derivative filters 4 | % optimized for accurate direction estimation. Coordinate system 5 | % corresponds to standard pixel indexing: X axis points rightward. Y 6 | % axis points downward. EDGES specify boundary handling (see corrDn 7 | % for options). 8 | % 9 | % Unlike matlab's new gradient function, which is based on local 10 | % differences, this function computes derivatives using 5x5 filters 11 | % designed to accurately reflect the local orientation content. 12 | 13 | % EPS, 1997. 14 | % original filters from Int'l Conf Image Processing, 1994. 15 | % updated filters 10/2003: see Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. 16 | % Incorporated into matlabPyrTools 10/2004. 17 | 18 | function [dx, dy] = imGradient(im, edges) 19 | 20 | if (exist('edges') ~= 1) 21 | edges = 'dont-compute'; 22 | end 23 | 24 | %% kernels from Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. 25 | gp = [0.037659 0.249153 0.426375 0.249153 0.037659]'; 26 | gd = [-0.109604 -0.276691 0.000000 0.276691 0.109604]'; 27 | 28 | dx = corrDn(corrDn(im, gp, edges), gd', edges); 29 | dy = corrDn(corrDn(im, gd, edges), gp', edges); 30 | 31 | return 32 | 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | %%% TEST: 35 | 36 | %%Make a ramp with random slope and direction 37 | dir = 2*pi*rand - pi; 38 | slope = 10*rand; 39 | 40 | sz = 32 41 | im = mkRamp(sz, dir, slope); 42 | [dx,dy] = imGradient(im); 43 | showIm(dx + sqrt(-1)*dy); 44 | 45 | ctr = (sz*sz/2)+sz/2; 46 | slopeEst = sqrt(dx(ctr).^2 + dy(ctr).^2); 47 | dirEst = atan2(dy(ctr), dx(ctr)); 48 | 49 | [slope, slopeEst] 50 | [dir, dirEst] 51 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/imStats.m: -------------------------------------------------------------------------------- 1 | % imStats(IM1,IM2) 2 | % 3 | % Report image (matrix) statistics. 4 | % When called on a single image IM1, report min, max, mean, stdev, skew, 5 | % and kurtosis (4th moment about the mean, divided by squared variance) 6 | % 7 | % When called on two images (IM1 and IM2), report min, max, mean, 8 | % stdev of the difference, and also SNR (relative to IM1). 9 | 10 | % Eero Simoncelli, 6/96. 11 | 12 | function [] = imStats(im1,im2) 13 | 14 | if (~isreal(im1)) 15 | error('Args must be real-valued matrices'); 16 | end 17 | 18 | if (exist('im2') == 1) 19 | difference = im1 - im2; 20 | [mn,mx] = range2(difference); 21 | mean = mean2(difference); 22 | v = var2(difference,mean); 23 | if (v < realmin) 24 | snr = Inf; 25 | else 26 | snr = 10 * log10(var2(im1)/v); 27 | end 28 | fprintf(1, 'Difference statistics:\n'); 29 | fprintf(1, ' Range: [%c, %c]\n',mn,mx); 30 | fprintf(1, ' Mean: %f, Stdev (rmse): %f, SNR (dB): %f\n',... 31 | mean,sqrt(v),snr); 32 | else 33 | [mn,mx] = range2(im1); 34 | mean = mean2(im1); 35 | var = var2(im1,mean); 36 | stdev = sqrt(real(var))+sqrt(imag(var)); 37 | sk = skew2(im1, mean, stdev^2); 38 | kurt = kurt2(im1, mean, stdev^2); 39 | fprintf(1, 'Image statistics:\n'); 40 | fprintf(1, ' Range: [%f, %f]\n',mn,mx); 41 | fprintf(1, ' Mean: %f, Stdev: %f, Skew: %f, Kurt: %f\n',mean,stdev,sk,kurt); 42 | end 43 | 44 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/innerProd.m: -------------------------------------------------------------------------------- 1 | % RES = innerProd(MTX) 2 | % 3 | % Compute (MTX' * MTX) efficiently (i.e., without copying the matrix) 4 | % 5 | % NOTE: This function used to call a MEX function (C code) to avoid copying, but 6 | % newer versions of matlab have eliminated the overhead of the 7 | % simpler form below. 8 | 9 | function res = innerProd(mtx) 10 | 11 | res = mtx' * mtx; 12 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/kurt2.m: -------------------------------------------------------------------------------- 1 | % K = KURT2(MTX,MEAN,VAR) 2 | % 3 | % Sample kurtosis (fourth moment divided by squared variance) 4 | % of a matrix. Kurtosis of a Gaussian distribution is 3. 5 | % MEAN (optional) and VAR (optional) make the computation faster. 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function res = kurt2(mtx, mn, v) 10 | 11 | if (exist('mn') ~= 1) 12 | mn = mean(mean(mtx)); 13 | end 14 | 15 | if (exist('v') ~= 1) 16 | v = var2(mtx,mn); 17 | end 18 | 19 | if (isreal(mtx)) 20 | res = mean(mean(abs(mtx-mn).^4)) / (v^2); 21 | else 22 | res = mean(mean(real(mtx-mn).^4)) / (real(v)^2) + ... 23 | i*mean(mean(imag(mtx-mn).^4)) / (imag(v)^2); 24 | end 25 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/lplot.m: -------------------------------------------------------------------------------- 1 | % lplot(VEC, XRANGE) 2 | % 3 | % Plot VEC, a vector, in "lollipop" format. 4 | % XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector 5 | % specifying the X positions (for labeling purposes) of the first and 6 | % last sample of VEC. 7 | 8 | % Mark Liberman, Linguistics Dept, UPenn, 1994. 9 | 10 | function lplot(x,xrange) 11 | 12 | if (exist('xrange') ~= 1) 13 | xrange = [1,length(x)]; 14 | end 15 | 16 | msize = size(x); 17 | if ( msize(2) == 1) 18 | x = x'; 19 | elseif (msize(1) ~= 1) 20 | error('First arg must be a vector'); 21 | end 22 | 23 | if (~isreal(x)) 24 | fprintf(1,'Warning: Imaginary part of signal ignored\n'); 25 | x = abs(x); 26 | end 27 | 28 | N = length(x); 29 | index = xrange(1) + (xrange(2)-xrange(1))*[0:(N-1)]/(N-1); 30 | xinc = index(2)-index(1); 31 | 32 | xx = [zeros(1,N);x;zeros(1,N)]; 33 | indexis = [index;index;index]; 34 | xdiscrete = [0 xx(:)' 0]; 35 | idiscrete = [index(1)-xinc indexis(:)' index(N)+xinc]; 36 | 37 | [mn,mx] = range2(xdiscrete); 38 | ypad = (mx-mn)/12; % MAGIC NUMBER: graph padding 39 | 40 | plot(idiscrete, xdiscrete, index, x, 'o'); 41 | axis([index(1)-xinc, index(N)+xinc, mn-ypad, mx+ypad]); 42 | 43 | return 44 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/lpyrHt.m: -------------------------------------------------------------------------------- 1 | % [HEIGHT] = lpyrHt(INDICES) 2 | % 3 | % Compute height of Laplacian pyramid with given its INDICES matrix. 4 | % See buildLpyr.m 5 | 6 | % Eero Simoncelli, 6/96. 7 | 8 | function [ht] = lpyrHt(pind) 9 | 10 | % Don't count lowpass residual band 11 | ht = size(pind,1)-1; 12 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/maxPyrHt.m: -------------------------------------------------------------------------------- 1 | % HEIGHT = maxPyrHt(IMSIZE, FILTSIZE) 2 | % 3 | % Compute maximum pyramid height for given image and filter sizes. 4 | % Specifically: the number of corrDn operations that can be sequentially 5 | % performed when subsampling by a factor of 2. 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function height = maxPyrHt(imsz, filtsz) 10 | 11 | imsz = imsz(:); 12 | filtsz = filtsz(:); 13 | 14 | if any(imsz == 1) % 1D image 15 | imsz = prod(imsz); 16 | filtsz = prod(filtsz); 17 | elseif any(filtsz == 1) % 2D image, 1D filter 18 | filtsz = [filtsz(1); filtsz(1)]; 19 | end 20 | 21 | if any(imsz < filtsz) 22 | height = 0; 23 | else 24 | height = 1 + maxPyrHt( floor(imsz/2), filtsz ); 25 | end 26 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mean2.m: -------------------------------------------------------------------------------- 1 | % M = MEAN2(MTX) 2 | % 3 | % Sample mean of a matrix. 4 | 5 | function res = mean2(mtx) 6 | 7 | res = mean(mean(mtx)); 8 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkAngle.m: -------------------------------------------------------------------------------- 1 | % IM = mkAngle(SIZE, PHASE, ORIGIN) 2 | % 3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) 4 | % containing samples of the polar angle (in radians, CW from the 5 | % X-axis, ranging from -pi to pi), relative to angle PHASE (default = 6 | % 0), about ORIGIN pixel (default = (size+1)/2). 7 | 8 | % Eero Simoncelli, 6/96. 9 | 10 | function [res] = mkAngle(sz, phase, origin) 11 | 12 | sz = sz(:); 13 | if (size(sz,1) == 1) 14 | sz = [sz,sz]; 15 | end 16 | 17 | % ----------------------------------------------------------------- 18 | % OPTIONAL args: 19 | 20 | if (exist('origin') ~= 1) 21 | origin = (sz+1)/2; 22 | end 23 | 24 | % ----------------------------------------------------------------- 25 | 26 | [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); 27 | 28 | res = atan2(yramp,xramp); 29 | 30 | if (exist('phase') == 1) 31 | res = mod(res+(pi-phase),2*pi)-pi; 32 | end 33 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkAngularSine.m: -------------------------------------------------------------------------------- 1 | % IM = mkAngularSine(SIZE, HARMONIC, AMPL, PHASE, ORIGIN) 2 | % 3 | % Make an angular sinusoidal image: 4 | % AMPL * sin( HARMONIC*theta + PHASE), 5 | % where theta is the angle about the origin. 6 | % SIZE specifies the matrix size, as for zeros(). 7 | % AMPL (default = 1) and PHASE (default = 0) are optional. 8 | 9 | % Eero Simoncelli, 2/97. 10 | 11 | function [res] = mkAngularSine(sz, harmonic, ampl, ph, origin) 12 | 13 | sz = sz(:); 14 | if (size(sz,1) == 1) 15 | sz = [sz,sz]; 16 | end 17 | 18 | mxsz = max(sz(1),sz(2)); 19 | 20 | %------------------------------------------------------------ 21 | %% OPTIONAL ARGS: 22 | 23 | if (exist('harmonic') ~= 1) 24 | harmonic = 1; 25 | end 26 | 27 | if (exist('ampl') ~= 1) 28 | ampl = 1; 29 | end 30 | 31 | if (exist('ph') ~= 1) 32 | ph = 0; 33 | end 34 | 35 | if (exist('origin') ~= 1) 36 | origin = (sz+1)/2; 37 | end 38 | 39 | %------------------------------------------------------------ 40 | 41 | res = ampl * sin(harmonic*mkAngle(sz,ph,origin) + ph); 42 | 43 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkDisc.m: -------------------------------------------------------------------------------- 1 | % IM = mkDisc(SIZE, RADIUS, ORIGIN, TWIDTH, VALS) 2 | % 3 | % Make a "disk" image. SIZE specifies the matrix size, as for 4 | % zeros(). RADIUS (default = min(size)/4) specifies the radius of 5 | % the disk. ORIGIN (default = (size+1)/2) specifies the 6 | % location of the disk center. TWIDTH (in pixels, default = 2) 7 | % specifies the width over which a soft threshold transition is made. 8 | % VALS (default = [0,1]) should be a 2-vector containing the 9 | % intensity value inside and outside the disk. 10 | 11 | % Eero Simoncelli, 6/96. 12 | 13 | function [res] = mkDisc(sz, rad, origin, twidth, vals) 14 | 15 | if (nargin < 1) 16 | error('Must pass at least a size argument'); 17 | end 18 | 19 | sz = sz(:); 20 | if (size(sz,1) == 1) 21 | sz = [sz sz]; 22 | end 23 | 24 | %------------------------------------------------------------ 25 | % OPTIONAL ARGS: 26 | 27 | if (exist('rad') ~= 1) 28 | rad = min(sz(1),sz(2))/4; 29 | end 30 | 31 | if (exist('origin') ~= 1) 32 | origin = (sz+1)./2; 33 | end 34 | 35 | if (exist('twidth') ~= 1) 36 | twidth = 2; 37 | end 38 | 39 | if (exist('vals') ~= 1) 40 | vals = [1,0]; 41 | end 42 | 43 | %------------------------------------------------------------ 44 | 45 | res = mkR(sz,1,origin); 46 | 47 | if (abs(twidth) < realmin) 48 | res = vals(2) + (vals(1) - vals(2)) * (res <= rad); 49 | else 50 | [Xtbl,Ytbl] = rcosFn(twidth, rad, [vals(1), vals(2)]); 51 | res = pointOp(res, Ytbl, Xtbl(1), Xtbl(2)-Xtbl(1), 0); 52 | % 53 | % OLD interp1 VERSION: 54 | % res = res(:); 55 | % Xtbl(1) = min(res); 56 | % Xtbl(size(Xtbl,2)) = max(res); 57 | % res = reshape(interp1(Xtbl,Ytbl,res), sz(1), sz(2)); 58 | % 59 | end 60 | 61 | 62 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkFract.m: -------------------------------------------------------------------------------- 1 | % IM = mkFract(SIZE, FRACT_DIM) 2 | % 3 | % Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar) 4 | % containing fractal (pink) noise with power spectral density of the 5 | % form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0. 6 | % FRACT_DIM defaults to 1.0 7 | 8 | % Eero Simoncelli, 6/96. 9 | 10 | %% TODO: Verify that this matches Mandelbrot defn of fractal dimension. 11 | %% Make this more efficient! 12 | 13 | function res = mkFract(dims, fract_dim) 14 | 15 | if (exist('fract_dim') ~= 1) 16 | fract_dim = 1.0; 17 | end 18 | 19 | res = randn(dims); 20 | fres = fft2(res); 21 | 22 | sz = size(res); 23 | ctr = ceil((sz+1)./2); 24 | 25 | shape = ifftshift(mkR(sz, -(2.5-fract_dim), ctr)); 26 | shape(1,1) = 1; %%DC term 27 | 28 | fres = shape .* fres; 29 | fres = ifft2(fres); 30 | 31 | if (max(max(abs(imag(fres)))) > 1e-10) 32 | error('Symmetry error in creating fractal'); 33 | else 34 | res = real(fres); 35 | res = res / sqrt(var2(res)); 36 | end 37 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkGaussian.m: -------------------------------------------------------------------------------- 1 | % IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE) 2 | % 3 | % Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a 4 | % scalar) containing a Gaussian function, centered at pixel position 5 | % specified by MEAN (default = (size+1)/2), with given COVARIANCE (can 6 | % be a scalar, 2-vector, or 2x2 matrix. Default = (min(size)/6)^2), 7 | % and AMPLITUDE. AMPLITUDE='norm' (default) will produce a 8 | % probability-normalized function. All but the first argument are 9 | % optional. 10 | 11 | % Eero Simoncelli, 6/96. 12 | 13 | function [res] = mkGaussian(sz, cov, mn, ampl) 14 | 15 | sz = sz(:); 16 | if (size(sz,1) == 1) 17 | sz = [sz,sz]; 18 | end 19 | 20 | %------------------------------------------------------------ 21 | %% OPTIONAL ARGS: 22 | 23 | if (exist('cov') ~= 1) 24 | cov = (min(sz(1),sz(2))/6)^2; 25 | end 26 | 27 | if ( (exist('mn') ~= 1) | isempty(mn) ) 28 | mn = (sz+1)/2; 29 | else 30 | mn = mn(:); 31 | if (size(mn,1) == 1) 32 | mn = [mn, mn]; 33 | end 34 | end 35 | 36 | if (exist('ampl') ~= 1) 37 | ampl = 'norm'; 38 | end 39 | 40 | %------------------------------------------------------------ 41 | 42 | [xramp,yramp] = meshgrid([1:sz(2)]-mn(2),[1:sz(1)]-mn(1)); 43 | 44 | if (sum(size(cov)) == 2) % scalar 45 | if (strcmp(ampl,'norm')) 46 | ampl = 1/(2*pi*cov(1)); 47 | end 48 | e = (xramp.^2 + yramp.^2)/(-2 * cov); 49 | elseif (sum(size(cov)) == 3) % a 2-vector 50 | if (strcmp(ampl,'norm')) 51 | ampl = 1/(2*pi*sqrt(cov(1)*cov(2))); 52 | end 53 | e = xramp.^2/(-2 * cov(2)) + yramp.^2/(-2 * cov(1)); 54 | else 55 | if (strcmp(ampl,'norm')) 56 | ampl = 1/(2*pi*sqrt(det(cov))); 57 | end 58 | cov = -inv(cov)/2; 59 | e = cov(2,2)*xramp.^2 + (cov(1,2)+cov(2,1))*(xramp.*yramp) ... 60 | + cov(1,1)*yramp.^2; 61 | end 62 | 63 | res = ampl .* exp(e); 64 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkImpulse.m: -------------------------------------------------------------------------------- 1 | % IM = mkImpulse(SIZE, ORIGIN, AMPLITUDE) 2 | % 3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) 4 | % containing a single non-zero entry, at position ORIGIN (defaults to 5 | % ceil(size/2)), of value AMPLITUDE (defaults to 1). 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function [res] = mkImpulse(sz, origin, amplitude) 10 | 11 | sz = sz(:)'; 12 | if (size(sz,2) == 1) 13 | sz = [sz sz]; 14 | end 15 | 16 | if (exist('origin') ~= 1) 17 | origin = ceil(sz/2); 18 | end 19 | 20 | if (exist('amplitude') ~= 1) 21 | amplitude = 1; 22 | end 23 | 24 | res = zeros(sz); 25 | res(origin(1),origin(2)) = amplitude; 26 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkR.m: -------------------------------------------------------------------------------- 1 | % IM = mkR(SIZE, EXPT, ORIGIN) 2 | % 3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) 4 | % containing samples of a radial ramp function, raised to power EXPT 5 | % (default = 1), with given ORIGIN (default = (size+1)/2, [1 1] = 6 | % upper left). All but the first argument are optional. 7 | 8 | % Eero Simoncelli, 6/96. 9 | 10 | function [res] = mkR(sz, expt, origin) 11 | 12 | sz = sz(:); 13 | if (size(sz,1) == 1) 14 | sz = [sz,sz]; 15 | end 16 | 17 | % ----------------------------------------------------------------- 18 | % OPTIONAL args: 19 | 20 | if (exist('expt') ~= 1) 21 | expt = 1; 22 | end 23 | 24 | if (exist('origin') ~= 1) 25 | origin = (sz+1)/2; 26 | end 27 | 28 | % ----------------------------------------------------------------- 29 | 30 | [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); 31 | 32 | res = (xramp.^2 + yramp.^2).^(expt/2); 33 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkRamp.m: -------------------------------------------------------------------------------- 1 | % IM = mkRamp(SIZE, DIRECTION, SLOPE, INTERCEPT, ORIGIN) 2 | % 3 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) 4 | % containing samples of a ramp function, with given gradient DIRECTION 5 | % (radians, CW from X-axis, default = 0), SLOPE (per pixel, default = 6 | % 1), and a value of INTERCEPT (default = 0) at the ORIGIN (default = 7 | % (size+1)/2, [1 1] = upper left). All but the first argument are 8 | % optional. 9 | 10 | % Eero Simoncelli, 6/96. 2/97: adjusted coordinate system. 11 | 12 | function [res] = mkRamp(sz, dir, slope, intercept, origin) 13 | 14 | sz = sz(:); 15 | if (size(sz,1) == 1) 16 | sz = [sz,sz]; 17 | end 18 | 19 | % ----------------------------------------------------------------- 20 | % OPTIONAL args: 21 | 22 | if (exist('dir') ~= 1) 23 | dir = 0; 24 | end 25 | 26 | if (exist('slope') ~= 1) 27 | slope = 1; 28 | end 29 | 30 | if (exist('intercept') ~= 1) 31 | intercept = 0; 32 | end 33 | 34 | if (exist('origin') ~= 1) 35 | origin = (sz+1)/2; 36 | end 37 | 38 | % ----------------------------------------------------------------- 39 | 40 | xinc = slope*cos(dir); 41 | yinc = slope*sin(dir); 42 | 43 | [xramp,yramp] = meshgrid( xinc*([1:sz(2)]-origin(2)), ... 44 | yinc*([1:sz(1)]-origin(1)) ); 45 | 46 | res = intercept + xramp + yramp; 47 | 48 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkSine.m: -------------------------------------------------------------------------------- 1 | % IM = mkSine(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN) 2 | % or 3 | % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN) 4 | % 5 | % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) 6 | % containing samples of a 2D sinusoid, with given PERIOD (in pixels), 7 | % DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE (default 8 | % = 1), and PHASE (radians, relative to ORIGIN, default = 0). ORIGIN 9 | % defaults to the center of the image. 10 | % 11 | % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). 12 | 13 | % Eero Simoncelli, 6/96. 14 | 15 | function [res] = mkSine(sz, per_freq, dir_amp, amp_phase, phase_orig, orig) 16 | 17 | %------------------------------------------------------------ 18 | %% OPTIONAL ARGS: 19 | 20 | if (prod(size(per_freq)) == 2) 21 | frequency = norm(per_freq); 22 | direction = atan2(per_freq(1),per_freq(2)); 23 | if (exist('dir_amp') == 1) 24 | amplitude = dir_amp; 25 | else 26 | amplitude = 1; 27 | end 28 | if (exist('amp_phase') == 1) 29 | phase = amp_phase; 30 | else 31 | phase = 0; 32 | end 33 | if (exist('phase_orig') == 1) 34 | origin = phase_orig; 35 | end 36 | if (exist('orig') == 1) 37 | error('Too many arguments for (second form) of mkSine'); 38 | end 39 | else 40 | frequency = 2*pi/per_freq; 41 | if (exist('dir_amp') == 1) 42 | direction = dir_amp; 43 | else 44 | direction = 0; 45 | end 46 | if (exist('amp_phase') == 1) 47 | amplitude = amp_phase; 48 | else 49 | amplitude = 1; 50 | end 51 | if (exist('phase_orig') == 1) 52 | phase = phase_orig; 53 | else 54 | phase = 0; 55 | end 56 | if (exist('orig') == 1) 57 | origin = orig; 58 | end 59 | end 60 | 61 | %------------------------------------------------------------ 62 | 63 | if (exist('origin') == 1) 64 | res = amplitude*sin(mkRamp(sz, direction, frequency, phase, origin)); 65 | else 66 | res = amplitude*sin(mkRamp(sz, direction, frequency, phase)); 67 | end 68 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/mkZonePlate.m: -------------------------------------------------------------------------------- 1 | % IM = mkZonePlate(SIZE, AMPL, PHASE) 2 | % 3 | % Make a "zone plate" image: 4 | % AMPL * cos( r^2 + PHASE) 5 | % SIZE specifies the matrix size, as for zeros(). 6 | % AMPL (default = 1) and PHASE (default = 0) are optional. 7 | 8 | % Eero Simoncelli, 6/96. 9 | 10 | function [res] = mkZonePlate(sz, ampl, ph) 11 | 12 | sz = sz(:); 13 | if (size(sz,1) == 1) 14 | sz = [sz,sz]; 15 | end 16 | 17 | mxsz = max(sz(1),sz(2)); 18 | 19 | %------------------------------------------------------------ 20 | %% OPTIONAL ARGS: 21 | 22 | if (exist('ampl') ~= 1) 23 | ampl = 1; 24 | end 25 | 26 | if (exist('ph') ~= 1) 27 | ph = 0; 28 | end 29 | 30 | %------------------------------------------------------------ 31 | 32 | res = ampl * cos( (pi/mxsz) * mkR(sz,2) + ph ); 33 | 34 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/modulateFlip.m: -------------------------------------------------------------------------------- 1 | % [HFILT] = modulateFlipShift(LFILT) 2 | % 3 | % QMF/Wavelet highpass filter construction: modulate by (-1)^n, 4 | % reverse order (and shift by one, which is handled by the convolution 5 | % routines). This is an extension of the original definition of QMF's 6 | % (e.g., see Simoncelli90). 7 | 8 | % Eero Simoncelli, 7/96. 9 | 10 | function [hfilt] = modulateFlipShift(lfilt) 11 | 12 | lfilt = lfilt(:); 13 | 14 | sz = size(lfilt,1); 15 | sz2 = ceil(sz/2); 16 | 17 | ind = [sz:-1:1]'; 18 | 19 | hfilt = lfilt(ind) .* (-1).^(ind-sz2); 20 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/nextFig.m: -------------------------------------------------------------------------------- 1 | % nextFig (MAXFIGS, SKIP) 2 | % 3 | % Make figure number mod((GCF+SKIP), MAXFIGS) the current figure. 4 | % MAXFIGS is optional, and defaults to 2. 5 | % SKIP is optional, and defaults to 1. 6 | 7 | % Eero Simoncelli, 2/97. 8 | 9 | function nextFig(maxfigs, skip) 10 | 11 | if (exist('maxfigs') ~= 1) 12 | maxfigs = 2; 13 | end 14 | 15 | if (exist('skip') ~= 1) 16 | skip = 1; 17 | end 18 | 19 | figure(1+mod(gcf-1+skip,maxfigs)); 20 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pgmRead.m: -------------------------------------------------------------------------------- 1 | % IM = pgmRead( FILENAME ) 2 | % 3 | % Load a pgm image into a MatLab matrix. 4 | % This format is accessible from the XV image browsing utility. 5 | % Only works for 8bit gray images (raw or ascii) 6 | 7 | % Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. 8 | 9 | function im = pgmRead( fname ); 10 | 11 | [fid,msg] = fopen( fname, 'r' ); 12 | 13 | if (fid == -1) 14 | error(msg); 15 | end 16 | 17 | %%% First line contains ID string: 18 | %%% "P1" = ascii bitmap, "P2" = ascii greymap, 19 | %%% "P3" = ascii pixmap, "P4" = raw bitmap, 20 | %%% "P5" = raw greymap, "P6" = raw pixmap 21 | TheLine = fgetl(fid); 22 | format = TheLine; 23 | 24 | if ~((format(1:2) == 'P2') | (format(1:2) == 'P5')) 25 | error('PGM file must be of type P2 or P5'); 26 | end 27 | 28 | %%% Any number of comment lines 29 | TheLine = fgetl(fid); 30 | while TheLine(1) == '#' 31 | TheLine = fgetl(fid); 32 | end 33 | 34 | %%% dimensions 35 | sz = sscanf(TheLine,'%d',2); 36 | xdim = sz(1); 37 | ydim = sz(2); 38 | sz = xdim * ydim; 39 | 40 | %%% Maximum pixel value 41 | TheLine = fgetl(fid); 42 | maxval = sscanf(TheLine, '%d',1); 43 | 44 | %%im = zeros(dim,1); 45 | if (format(2) == '2') 46 | [im,count] = fscanf(fid,'%d',sz); 47 | else 48 | [im,count] = fread(fid,sz,'uchar'); 49 | end 50 | 51 | fclose(fid); 52 | 53 | if (count == sz) 54 | im = reshape( im, xdim, ydim )'; 55 | else 56 | fprintf(1,'Warning: File ended early!'); 57 | im = reshape( [im ; zeros(sz-count,1)], xdim, ydim)'; 58 | end 59 | 60 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pixelAxes.m: -------------------------------------------------------------------------------- 1 | % [ZOOM] = pixelAxes(DIMS, ZOOM) 2 | % 3 | % Set the axes of the current plot to cover a multiple of DIMS pixels, 4 | % thereby eliminating screen aliasing artifacts when displaying an 5 | % image of size DIMS. 6 | % 7 | % ZOOM (optional, default='same') expresses the desired number of 8 | % samples displayed per screen pixel. It should be a scalar, which 9 | % will be rounded to the nearest integer, or 1 over an integer. It 10 | % may also be the string 'same' or 'auto', in which case the value is chosen so 11 | % as to produce an image closest in size to the currently displayed 12 | % image. It may also be the string 'full', in which case the image is 13 | % made as large as possible while still fitting in the window. 14 | 15 | % Eero Simoncelli, 2/97. 16 | 17 | function [zoom] = pixelAxes(dims, zoom) 18 | 19 | %------------------------------------------------------------ 20 | %% OPTIONAL ARGS: 21 | 22 | if (exist('zoom') ~= 1) 23 | zoom = 'same'; 24 | end 25 | 26 | %% Reverse dimension order, since Figure Positions reported as (x,y). 27 | dims = dims(2:-1:1); 28 | 29 | %% Use MatLab's axis function to force square pixels, etc: 30 | axis('image'); 31 | ax = gca; 32 | 33 | oldunits = get(ax,'Units'); 34 | 35 | if strcmp(zoom,'full'); 36 | set(ax,'Units','normalized'); 37 | set(ax,'Position',[0 0 1 1]); 38 | zoom = 'same'; 39 | end 40 | 41 | set(ax,'Units','pixels'); 42 | pos = get(ax,'Position'); 43 | ctr = pos(1:2)+pos(3:4)/2; 44 | 45 | if (strcmp(zoom,'same') | strcmp(zoom,'auto')) 46 | %% HACK: enlarge slightly so that floor doesn't round down 47 | zoom = min( pos(3:4) ./ (dims - 1) ); 48 | elseif isstr(zoom) 49 | error(sprintf('Bad ZOOM argument: %s',zoom)); 50 | end 51 | 52 | %% Force zoom value to be an integer, or inverse integer. 53 | if (zoom < 0.75) 54 | zoom = 1/ceil(1/zoom); 55 | %% Round upward, subtracting 0.5 to avoid floating point errors. 56 | newsz = ceil(zoom*(dims-0.5)); 57 | else 58 | zoom = floor(zoom + 0.001); % Avoid floating pt errors 59 | if (zoom < 1.5) % zoom=1 60 | zoom = 1; 61 | newsz = dims + 0.5; 62 | else 63 | newsz = zoom*(dims-1) + mod(zoom,2); 64 | end 65 | end 66 | 67 | set(ax,'Position', [floor(ctr-newsz/2)+0.5, newsz] ) 68 | 69 | % Restore units 70 | set(ax,'Units',oldunits); 71 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pointOp.m: -------------------------------------------------------------------------------- 1 | % RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS) 2 | % 3 | % Apply a point operation, specified by lookup table LUT, to image IM. 4 | % LUT must be a row or column vector, and is assumed to contain 5 | % (equi-spaced) samples of the function. ORIGIN specifies the 6 | % abscissa associated with the first sample, and INCREMENT specifies the 7 | % spacing between samples. Between-sample values are estimated via 8 | % linear interpolation. If WARNINGS is non-zero, the function prints 9 | % a warning whenever the lookup table is extrapolated. 10 | % 11 | % This function is much faster than MatLab's interp1, and allows 12 | % extrapolation beyond the lookup table domain. The drawbacks are 13 | % that the lookup table must be equi-spaced, and the interpolation is 14 | % linear. 15 | 16 | % Eero Simoncelli, 8/96. 17 | 18 | function res = pointOp(im, lut, origin, increment, warnings) 19 | 20 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) 21 | 22 | fprintf(1,'WARNING: You should compile the MEX version of "pointOp.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); 23 | 24 | X = origin + increment*[0:size(lut(:),1)-1]; 25 | Y = lut(:); 26 | 27 | res = reshape(interp1(X, Y, im(:), 'linear', 'extrap'),size(im)); 28 | 29 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pwd2path.m: -------------------------------------------------------------------------------- 1 | % PWD2PATH() 2 | % 3 | % add current working directory (pwd) to path. 4 | 5 | P = path; 6 | path(pwd,P); 7 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pyrBand.m: -------------------------------------------------------------------------------- 1 | % RES = pyrBand(PYR, INDICES, BAND_NUM) 2 | % 3 | % Access a subband from a pyramid (gaussian, laplacian, QMF/wavelet, 4 | % or steerable). Subbands are numbered consecutively, from finest 5 | % (highest spatial frequency) to coarsest (lowest spatial frequency). 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function res = pyrBand(pyr, pind, band) 10 | 11 | res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); 12 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pyrBandIndices.m: -------------------------------------------------------------------------------- 1 | % RES = pyrBandIndices(INDICES, BAND_NUM) 2 | % 3 | % Return indices for accessing a subband from a pyramid 4 | % (gaussian, laplacian, QMF/wavelet, steerable). 5 | 6 | % Eero Simoncelli, 6/96. 7 | 8 | function indices = pyrBandIndices(pind,band) 9 | 10 | if ((band > size(pind,1)) | (band < 1)) 11 | error(sprintf('BAND_NUM must be between 1 and number of pyramid bands (%d).', ... 12 | size(pind,1))); 13 | end 14 | 15 | if (size(pind,2) ~= 2) 16 | error('INDICES must be an Nx2 matrix indicating the size of the pyramid subbands'); 17 | end 18 | 19 | ind = 1; 20 | for l=1:band-1 21 | ind = ind + prod(pind(l,:)); 22 | end 23 | 24 | indices = ind:ind+prod(pind(band,:))-1; 25 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/pyrLow.m: -------------------------------------------------------------------------------- 1 | % RES = pyrLow(PYR, INDICES) 2 | % 3 | % Access the lowpass subband from a pyramid 4 | % (gaussian, laplacian, QMF/wavelet, steerable). 5 | 6 | % Eero Simoncelli, 6/96. 7 | 8 | function res = pyrLow(pyr,pind) 9 | 10 | band = size(pind,1); 11 | 12 | res = reshape( pyr(pyrBandIndices(pind,band)), pind(band,1), pind(band,2) ); 13 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/range2.m: -------------------------------------------------------------------------------- 1 | % [MIN, MAX] = range2(MTX) 2 | % 3 | % Compute minimum and maximum values of MTX, returning them as a 2-vector. 4 | 5 | % Eero Simoncelli, 3/97. 6 | 7 | function [mn, mx] = range2(mtx) 8 | 9 | %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) 10 | 11 | fprintf(1,'WARNING: You should compile the MEX version of "range2.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); 12 | 13 | if (~isreal(mtx)) 14 | error('MTX must be real-valued'); 15 | end 16 | 17 | mn = min(min(mtx)); 18 | mx = max(max(mtx)); 19 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/rconv2.m: -------------------------------------------------------------------------------- 1 | % RES = RCONV2(MTX1, MTX2, CTR) 2 | % 3 | % Convolution of two matrices, with boundaries handled via reflection 4 | % about the edge pixels. Result will be of size of LARGER matrix. 5 | % 6 | % The origin of the smaller matrix is assumed to be its center. 7 | % For even dimensions, the origin is determined by the CTR (optional) 8 | % argument: 9 | % CTR origin 10 | % 0 DIM/2 (default) 11 | % 1 (DIM/2)+1 12 | 13 | % Eero Simoncelli, 6/96. 14 | 15 | function c = rconv2(a,b,ctr) 16 | 17 | if (exist('ctr') ~= 1) 18 | ctr = 0; 19 | end 20 | 21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) 22 | large = a; small = b; 23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) 24 | large = b; small = a; 25 | else 26 | error('one arg must be larger than the other in both dimensions!'); 27 | end 28 | 29 | ly = size(large,1); 30 | lx = size(large,2); 31 | sy = size(small,1); 32 | sx = size(small,2); 33 | 34 | %% These values are one less than the index of the small mtx that falls on 35 | %% the border pixel of the large matrix when computing the first 36 | %% convolution response sample: 37 | sy2 = floor((sy+ctr-1)/2); 38 | sx2 = floor((sx+ctr-1)/2); 39 | 40 | % pad with reflected copies 41 | clarge = [ 42 | large(sy-sy2:-1:2,sx-sx2:-1:2), large(sy-sy2:-1:2,:), ... 43 | large(sy-sy2:-1:2,lx-1:-1:lx-sx2); ... 44 | large(:,sx-sx2:-1:2), large, large(:,lx-1:-1:lx-sx2); ... 45 | large(ly-1:-1:ly-sy2,sx-sx2:-1:2), ... 46 | large(ly-1:-1:ly-sy2,:), ... 47 | large(ly-1:-1:ly-sy2,lx-1:-1:lx-sx2) ]; 48 | 49 | c = conv2(clarge,small,'valid'); 50 | 51 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/rcosFn.m: -------------------------------------------------------------------------------- 1 | % [X, Y] = rcosFn(WIDTH, POSITION, VALUES) 2 | % 3 | % Return a lookup table (suitable for use by INTERP1) 4 | % containing a "raised cosine" soft threshold function: 5 | % 6 | % Y = VALUES(1) + (VALUES(2)-VALUES(1)) * 7 | % cos^2( PI/2 * (X - POSITION + WIDTH)/WIDTH ) 8 | % 9 | % WIDTH is the width of the region over which the transition occurs 10 | % (default = 1). POSITION is the location of the center of the 11 | % threshold (default = 0). VALUES (default = [0,1]) specifies the 12 | % values to the left and right of the transition. 13 | 14 | % Eero Simoncelli, 7/96. 15 | 16 | function [X, Y] = rcosFn(width,position,values) 17 | 18 | %------------------------------------------------------------ 19 | % OPTIONAL ARGS: 20 | 21 | if (exist('width') ~= 1) 22 | width = 1; 23 | end 24 | 25 | if (exist('position') ~= 1) 26 | position = 0; 27 | end 28 | 29 | if (exist('values') ~= 1) 30 | values = [0,1]; 31 | end 32 | 33 | %------------------------------------------------------------ 34 | 35 | sz = 256; %% arbitrary! 36 | 37 | X = pi * [-sz-1:1] / (2*sz); 38 | 39 | Y = values(1) + (values(2)-values(1)) * cos(X).^2; 40 | 41 | % Make sure end values are repeated, for extrapolation... 42 | Y(1) = Y(2); 43 | Y(sz+3) = Y(sz+2); 44 | 45 | X = position + (2*width/pi) * (X + pi/4); 46 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/reconSFpyrLevs.m: -------------------------------------------------------------------------------- 1 | % RESDFT = reconSFpyrLevs(PYR,INDICES,LOGRAD,XRCOS,YRCOS,ANGLE,NBANDS,LEVS,BANDS) 2 | % 3 | % Recursive function for reconstructing levels of a steerable pyramid 4 | % representation. This is called by reconSFpyr, and is not usually 5 | % called directly. 6 | 7 | % Eero Simoncelli, 5/97. 8 | 9 | function resdft = reconSFpyrLevs(pyr,pind,log_rad,Xrcos,Yrcos,angle,nbands,levs,bands); 10 | 11 | lo_ind = nbands+1; 12 | dims = pind(1,:); 13 | ctr = ceil((dims+0.5)/2); 14 | 15 | % log_rad = log_rad + 1; 16 | Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. 17 | 18 | if any(levs > 1) 19 | 20 | lodims = ceil((dims-0.5)/2); 21 | loctr = ceil((lodims+0.5)/2); 22 | lostart = ctr-loctr+1; 23 | loend = lostart+lodims-1; 24 | nlog_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); 25 | nangle = angle(lostart(1):loend(1),lostart(2):loend(2)); 26 | 27 | if (size(pind,1) > lo_ind) 28 | nresdft = reconSFpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)),... 29 | pind(lo_ind:size(pind,1),:), ... 30 | nlog_rad, Xrcos, Yrcos, nangle, nbands,levs-1, bands); 31 | else 32 | nresdft = fftshift(fft2(pyrBand(pyr,pind,lo_ind))); 33 | end 34 | 35 | YIrcos = sqrt(abs(1.0 - Yrcos.^2)); 36 | lomask = pointOp(nlog_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); 37 | 38 | resdft = zeros(dims); 39 | resdft(lostart(1):loend(1),lostart(2):loend(2)) = nresdft .* lomask; 40 | 41 | else 42 | 43 | resdft = zeros(dims); 44 | 45 | end 46 | 47 | 48 | if any(levs == 1) 49 | 50 | lutsize = 1024; 51 | Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] 52 | order = nbands-1; 53 | %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) 54 | const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); 55 | Ycosn = sqrt(const) * (cos(Xcosn)).^order; 56 | himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1),0); 57 | 58 | ind = 1; 59 | for b = 1:nbands 60 | if any(bands == b) 61 | anglemask = pointOp(angle,Ycosn,Xcosn(1)+pi*(b-1)/nbands,Xcosn(2)-Xcosn(1)); 62 | band = reshape(pyr(ind:ind+prod(dims)-1), dims(1), dims(2)); 63 | banddft = fftshift(fft2(band)); 64 | resdft = resdft + (sqrt(-1))^(nbands-1) * banddft.*anglemask.*himask; 65 | end 66 | ind = ind + prod(dims); 67 | end 68 | end 69 | 70 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/reconSpyrLevs.m: -------------------------------------------------------------------------------- 1 | % RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS) 2 | % 3 | % Recursive function for reconstructing levels of a steerable pyramid 4 | % representation. This is called by reconSpyr, and is not usually 5 | % called directly. 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands); 10 | 11 | nbands = size(bfilts,2); 12 | lo_ind = nbands+1; 13 | res_sz = pind(1,:); 14 | 15 | % Assume square filters: 16 | bfiltsz = round(sqrt(size(bfilts,1))); 17 | 18 | if any(levs > 1) 19 | 20 | if (size(pind,1) > lo_ind) 21 | nres = reconSpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)), ... 22 | pind(lo_ind:size(pind,1),:), ... 23 | lofilt, bfilts, edges, levs-1, bands); 24 | else 25 | nres = pyrBand(pyr,pind,lo_ind); % lowpass subband 26 | end 27 | 28 | res = upConv(nres, lofilt, edges, [2 2], [1 1], res_sz); 29 | 30 | else 31 | 32 | res = zeros(res_sz); 33 | 34 | end 35 | 36 | if any(levs == 1) 37 | ind = 1; 38 | for b = 1:nbands 39 | if any(bands == b) 40 | bfilt = reshape(bfilts(:,b), bfiltsz, bfiltsz); 41 | res = upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ... 42 | bfilt, edges, [1 1], [1 1], res_sz, res); 43 | end 44 | ind = ind + prod(res_sz); 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/setPyrBand.m: -------------------------------------------------------------------------------- 1 | % NEWPYR = setPyrBand(PYR, INDICES, NEWBAND, BAND_NUM) 2 | % 3 | % Insert an image (BAND) into a pyramid (gaussian, laplacian, QMF/wavelet, 4 | % or steerable). Subbands are numbered consecutively, from finest 5 | % (highest spatial frequency) to coarsest (lowest spatial frequency). 6 | 7 | % Eero Simoncelli, 1/03. 8 | 9 | function pyr = setPyrBand(pyr, pind, band, bandNum) 10 | 11 | %% Check: PIND a valid index matrix? 12 | if ( ~(ndims(pind) == 2) | ~(size(pind,2) == 2) | ~all(pind==round(pind)) ) 13 | pind 14 | error('pyrTools:badArg',... 15 | 'PIND argument is not an Nbands X 2 matrix of integers'); 16 | end 17 | 18 | %% Check: PIND consistent with size of PYR? 19 | if ( length(pyr) ~= sum(prod(pind,2)) ) 20 | error('pyrTools:badPyr',... 21 | 'Pyramid data vector length is inconsistent with index matrix PIND'); 22 | end 23 | 24 | %% Check: size of BAND consistent with desired BANDNUM? 25 | if (~all(size(band) == pind(bandNum,:))) 26 | size(band) 27 | pind(bandNum,:) 28 | error('pyrTools:badArg',... 29 | 'size of BAND to be inserted is inconsistent with BAND_NUM'); 30 | end 31 | 32 | pyr(pyrBandIndices(pind,bandNum)) = vectify(band); 33 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/shift.m: -------------------------------------------------------------------------------- 1 | % [RES] = shift(MTX, OFFSET) 2 | % 3 | % Circular shift 2D matrix samples by OFFSET (a [Y,X] 2-vector), 4 | % such that RES(POS) = MTX(POS-OFFSET). 5 | 6 | function res = shift(mtx, offset) 7 | 8 | dims = size(mtx); 9 | 10 | offset = mod(-offset,dims); 11 | 12 | res = [ mtx(offset(1)+1:dims(1), offset(2)+1:dims(2)), ... 13 | mtx(offset(1)+1:dims(1), 1:offset(2)); ... 14 | mtx(1:offset(1), offset(2)+1:dims(2)), ... 15 | mtx(1:offset(1), 1:offset(2)) ]; 16 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/skew2.m: -------------------------------------------------------------------------------- 1 | % S = SKEW2(MTX,MEAN,VAR) 2 | % 3 | % Sample skew (third moment divided by variance^3/2) of a matrix. 4 | % MEAN (optional) and VAR (optional) make the computation faster. 5 | 6 | function res = skew2(mtx, mn, v) 7 | 8 | if (exist('mn') ~= 1) 9 | mn = mean2(mtx); 10 | end 11 | 12 | if (exist('v') ~= 1) 13 | v = var2(mtx,mn); 14 | end 15 | 16 | if (isreal(mtx)) 17 | res = mean(mean((mtx-mn).^3)) / (v^(3/2)); 18 | else 19 | res = mean(mean(real(mtx-mn).^3)) / (real(v)^(3/2)) + ... 20 | i * mean(mean(imag(mtx-mn).^3)) / (imag(v)^(3/2)); 21 | end 22 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/spyrBand.m: -------------------------------------------------------------------------------- 1 | % [LEV,IND] = spyrBand(PYR,INDICES,LEVEL,BAND) 2 | % 3 | % Access a band from a steerable pyramid. 4 | % 5 | % LEVEL indicates the scale (finest = 1, coarsest = spyrHt(INDICES)). 6 | % 7 | % BAND (optional, default=1) indicates which subband 8 | % (1 = vertical, rest proceeding anti-clockwise). 9 | 10 | % Eero Simoncelli, 6/96. 11 | 12 | function res = spyrBand(pyr,pind,level,band) 13 | 14 | if (exist('level') ~= 1) 15 | level = 1; 16 | end 17 | 18 | if (exist('band') ~= 1) 19 | band = 1; 20 | end 21 | 22 | nbands = spyrNumBands(pind); 23 | if ((band > nbands) | (band < 1)) 24 | error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); 25 | end 26 | 27 | maxLev = spyrHt(pind); 28 | if ((level > maxLev) | (level < 1)) 29 | error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); 30 | end 31 | 32 | firstband = 1 + band + nbands*(level-1); 33 | res = pyrBand(pyr, pind, firstband); 34 | 35 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/spyrHigh.m: -------------------------------------------------------------------------------- 1 | % RES = spyrHigh(PYR, INDICES) 2 | % 3 | % Access the highpass residual band from a steerable pyramid. 4 | 5 | % Eero Simoncelli, 6/96. 6 | 7 | function res = spyrHigh(pyr,pind) 8 | 9 | res = pyrBand(pyr, pind, 1); 10 | 11 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/spyrHt.m: -------------------------------------------------------------------------------- 1 | % [HEIGHT] = spyrHt(INDICES) 2 | % 3 | % Compute height of steerable pyramid with given index matrix. 4 | 5 | % Eero Simoncelli, 6/96. 6 | 7 | function [ht] = spyrHt(pind) 8 | 9 | nbands = spyrNumBands(pind); 10 | 11 | % Don't count lowpass, or highpass residual bands 12 | if (size(pind,1) > 2) 13 | ht = (size(pind,1)-2)/nbands; 14 | else 15 | ht = 0; 16 | end 17 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/spyrLev.m: -------------------------------------------------------------------------------- 1 | % [LEV,IND] = spyrLev(PYR,INDICES,LEVEL) 2 | % 3 | % Access a level from a steerable pyramid. 4 | % Return as an SxB matrix, B = number of bands, S = total size of a band. 5 | % Also returns an Bx2 matrix containing dimensions of the subbands. 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function [lev,ind] = spyrLev(pyr,pind,level) 10 | 11 | nbands = spyrNumBands(pind); 12 | 13 | if ((level > spyrHt(pind)) | (level < 1)) 14 | error(sprintf('Level number must be in the range [1, %d].', spyrHt(pind))); 15 | end 16 | 17 | firstband = 2 + nbands*(level-1); 18 | firstind = 1; 19 | for l=1:firstband-1 20 | firstind = firstind + prod(pind(l,:)); 21 | end 22 | 23 | ind = pind(firstband:firstband+nbands-1,:); 24 | lev = pyr(firstind:firstind+sum(prod(ind'))-1); 25 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/spyrNumBands.m: -------------------------------------------------------------------------------- 1 | % [NBANDS] = spyrNumBands(INDICES) 2 | % 3 | % Compute number of orientation bands in a steerable pyramid with 4 | % given index matrix. If the pyramid contains only the highpass and 5 | % lowpass bands (i.e., zero levels), returns 0. 6 | 7 | % Eero Simoncelli, 2/97. 8 | 9 | function [nbands] = spyrNumBands(pind) 10 | 11 | if (size(pind,1) == 2) 12 | nbands = 0; 13 | else 14 | % Count number of orientation bands: 15 | b = 3; 16 | while ((b <= size(pind,1)) & all( pind(b,:) == pind(2,:)) ) 17 | b = b+1; 18 | end 19 | nbands = b-2; 20 | end 21 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/steer.m: -------------------------------------------------------------------------------- 1 | % RES = STEER(BASIS, ANGLE, HARMONICS, STEERMTX) 2 | % 3 | % Steer BASIS to the specfied ANGLE. 4 | % 5 | % BASIS should be a matrix whose columns are vectorized rotated copies of a 6 | % steerable function, or the responses of a set of steerable filters. 7 | % 8 | % ANGLE can be a scalar, or a column vector the size of the basis. 9 | % 10 | % HARMONICS (optional, default is N even or odd low frequencies, as for 11 | % derivative filters) should be a list of harmonic numbers indicating 12 | % the angular harmonic content of the basis. 13 | % 14 | % STEERMTX (optional, default assumes cosine phase harmonic components, 15 | % and filter positions at 2pi*n/N) should be a matrix which maps 16 | % the filters onto Fourier series components (ordered [cos0 cos1 sin1 17 | % cos2 sin2 ... sinN]). See steer2HarmMtx.m 18 | 19 | % Eero Simoncelli, 7/96. 20 | 21 | function res = steer(basis,angle,harmonics,steermtx) 22 | 23 | num = size(basis,2); 24 | 25 | if ( any(size(angle) ~= [size(basis,1) 1]) & any(size(angle) ~= [1 1]) ) 26 | error('ANGLE must be a scalar, or a column vector the size of the basis elements'); 27 | end 28 | 29 | %% If HARMONICS are not passed, assume derivatives. 30 | if (exist('harmonics') ~= 1) 31 | if (mod(num,2) == 0) 32 | harmonics = [0:(num/2)-1]'*2 + 1; 33 | else 34 | harmonics = [0:(num-1)/2]'*2; 35 | end 36 | else 37 | harmonics = harmonics(:); 38 | if ((2*size(harmonics,1)-any(harmonics == 0)) ~= num) 39 | error('harmonics list is incompatible with basis size'); 40 | end 41 | end 42 | 43 | %% If STEERMTX not passed, assume evenly distributed cosine-phase filters: 44 | if (exist('steermtx') ~= 1) 45 | steermtx = steer2HarmMtx(harmonics, pi*[0:num-1]/num, 'even'); 46 | end 47 | 48 | steervect = zeros(size(angle,1),num); 49 | arg = angle * harmonics(find(harmonics~=0))'; 50 | if (all(harmonics)) 51 | steervect(:, 1:2:num) = cos(arg); 52 | steervect(:, 2:2:num) = sin(arg); 53 | else 54 | steervect(:, 1) = ones(size(arg,1),1); 55 | steervect(:, 2:2:num) = cos(arg); 56 | steervect(:, 3:2:num) = sin(arg); 57 | end 58 | 59 | steervect = steervect * steermtx; 60 | 61 | if (size(steervect,1) > 1) 62 | tmp = basis' .* steervect'; 63 | res = sum(tmp)'; 64 | else 65 | res = basis * steervect'; 66 | end 67 | 68 | 69 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/steer2HarmMtx.m: -------------------------------------------------------------------------------- 1 | % MTX = steer2HarmMtx(HARMONICS, ANGLES, REL_PHASES) 2 | % 3 | % Compute a steering matrix (maps a directional basis set onto the 4 | % angular Fourier harmonics). HARMONICS is a vector specifying the 5 | % angular harmonics contained in the steerable basis/filters. ANGLES 6 | % (optional) is a vector specifying the angular position of each filter. 7 | % REL_PHASES (optional, default = 'even') specifies whether the harmonics 8 | % are cosine or sine phase aligned about those positions. 9 | % The result matrix is suitable for passing to the function STEER. 10 | 11 | % Eero Simoncelli, 7/96. 12 | 13 | function mtx = steer2HarmMtx(harmonics, angles, evenorodd) 14 | 15 | %%================================================================= 16 | %%% Optional Parameters: 17 | 18 | if (exist('evenorodd') ~= 1) 19 | evenorodd = 'even'; 20 | end 21 | 22 | % Make HARMONICS a row vector 23 | harmonics = harmonics(:)'; 24 | 25 | numh = 2*size(harmonics,2) - any(harmonics == 0); 26 | 27 | if (exist('angles') ~= 1) 28 | angles = pi * [0:numh-1]'/numh; 29 | else 30 | angles = angles(:); 31 | end 32 | 33 | %%================================================================= 34 | 35 | if isstr(evenorodd) 36 | if strcmp(evenorodd,'even') 37 | evenorodd = 0; 38 | elseif strcmp(evenorodd,'odd') 39 | evenorodd = 1; 40 | else 41 | error('EVEN_OR_ODD should be the string EVEN or ODD'); 42 | end 43 | end 44 | 45 | %% Compute inverse matrix, which maps Fourier components onto 46 | %% steerable basis. 47 | imtx = zeros(size(angles,1),numh); 48 | col = 1; 49 | for h=harmonics 50 | args = h*angles; 51 | if (h == 0) 52 | imtx(:,col) = ones(size(angles)); 53 | col = col+1; 54 | elseif evenorodd 55 | imtx(:,col) = sin(args); 56 | imtx(:,col+1) = -cos(args); 57 | col = col+2; 58 | else 59 | imtx(:,col) = cos(args); 60 | imtx(:,col+1) = sin(args); 61 | col = col+2; 62 | end 63 | end 64 | 65 | r = rank(imtx); 66 | if (( r ~= numh ) & ( r ~= size(angles,1) )) 67 | fprintf(2,'WARNING: matrix is not full rank'); 68 | end 69 | 70 | mtx = pinv(imtx); 71 | 72 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/subMtx.m: -------------------------------------------------------------------------------- 1 | % MTX = subMtx(VEC, DIMENSIONS, START_INDEX) 2 | % 3 | % Reshape a portion of VEC starting from START_INDEX (optional, 4 | % default=1) to the given dimensions. 5 | 6 | % Eero Simoncelli, 6/96. 7 | 8 | function mtx = subMtx(vec, sz, offset) 9 | 10 | if (exist('offset') ~= 1) 11 | offset = 1; 12 | end 13 | 14 | vec = vec(:); 15 | sz = sz(:); 16 | 17 | if (size(sz,1) ~= 2) 18 | error('DIMENSIONS must be a 2-vector.'); 19 | end 20 | 21 | mtx = reshape( vec(offset:offset+prod(sz)-1), sz(1), sz(2) ); 22 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/upBlur.m: -------------------------------------------------------------------------------- 1 | % RES = upBlur(IM, LEVELS, FILT) 2 | % 3 | % Upsample and blur an image. The blurring is done with filter 4 | % kernel specified by FILT (default = 'binom5'), which can be a string 5 | % (to be passed to namedFilter), a vector (applied separably as a 1D 6 | % convolution kernel in X and Y), or a matrix (applied as a 2D 7 | % convolution kernel). The downsampling is always by 2 in each 8 | % direction. 9 | % 10 | % The procedure is applied recursively LEVELS times (default=1). 11 | 12 | % Eero Simoncelli, 4/97. 13 | 14 | function res = upBlur(im, nlevs, filt) 15 | 16 | %------------------------------------------------------------ 17 | %% OPTIONAL ARGS: 18 | 19 | if (exist('nlevs') ~= 1) 20 | nlevs = 1; 21 | end 22 | 23 | if (exist('filt') ~= 1) 24 | filt = 'binom5'; 25 | end 26 | 27 | %------------------------------------------------------------ 28 | 29 | if isstr(filt) 30 | filt = namedFilter(filt); 31 | end 32 | 33 | if nlevs > 1 34 | im = upBlur(im,nlevs-1,filt); 35 | end 36 | 37 | if (nlevs >= 1) 38 | if (any(size(im)==1)) 39 | if (size(im,1)==1) 40 | filt = filt'; 41 | end 42 | res = upConv(im,filt,'reflect1',(size(im)~=1)+1); 43 | elseif (any(size(filt)==1)) 44 | filt = filt(:); 45 | res = upConv(im,filt,'reflect1',[2 1]); 46 | res = upConv(res,filt','reflect1',[1 2]); 47 | else 48 | res = upConv(im,filt,'reflect1',[2 2]); 49 | end 50 | else 51 | res = im; 52 | end 53 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/var2.m: -------------------------------------------------------------------------------- 1 | % V = VAR2(MTX,MEAN) 2 | % 3 | % Sample variance of a matrix. 4 | % Passing MEAN (optional) makes the calculation faster. 5 | 6 | function res = var2(mtx, mn) 7 | 8 | if (exist('mn') ~= 1) 9 | mn = mean2(mtx); 10 | end 11 | 12 | if (isreal(mtx)) 13 | res = sum(sum(abs(mtx-mn).^2)) / max((prod(size(mtx)) - 1),1); 14 | else 15 | res = sum(sum(real(mtx-mn).^2)) + i*sum(sum(imag(mtx-mn).^2)); 16 | res = res / max((prod(size(mtx)) - 1),1); 17 | end 18 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/vectify.m: -------------------------------------------------------------------------------- 1 | % [VEC] = columnize(MTX) 2 | % 3 | % Pack elements of MTX into a column vector. Just provides a 4 | % function-call notatoin for the operation MTX(:) 5 | 6 | function vec = columnize(mtx) 7 | 8 | vec = mtx(:); 9 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/wpyrBand.m: -------------------------------------------------------------------------------- 1 | % RES = wpyrBand(PYR, INDICES, LEVEL, BAND) 2 | % 3 | % Access a subband from a separable QMF/wavelet pyramid. 4 | % 5 | % LEVEL (optional, default=1) indicates the scale (finest = 1, 6 | % coarsest = wpyrHt(INDICES)). 7 | % 8 | % BAND (optional, default=1) indicates which subband (1=horizontal, 9 | % 2=vertical, 3=diagonal). 10 | 11 | % Eero Simoncelli, 6/96. 12 | 13 | function im = wpyrBand(pyr,pind,level,band) 14 | 15 | if (exist('level') ~= 1) 16 | level = 1; 17 | end 18 | 19 | if (exist('band') ~= 1) 20 | band = 1; 21 | end 22 | 23 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) 24 | nbands = 1; 25 | else 26 | nbands = 3; 27 | end 28 | 29 | if ((band > nbands) | (band < 1)) 30 | error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); 31 | end 32 | 33 | maxLev = wpyrHt(pind); 34 | if ((level > maxLev) | (level < 1)) 35 | error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); 36 | end 37 | 38 | band = band + nbands*(level-1); 39 | im = pyrBand(pyr,pind,band); 40 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/wpyrHt.m: -------------------------------------------------------------------------------- 1 | % [HEIGHT] = wpyrHt(INDICES) 2 | % 3 | % Compute height of separable QMF/wavelet pyramid with given index matrix. 4 | 5 | % Eero Simoncelli, 6/96. 6 | 7 | function [ht] = wpyrHt(pind) 8 | 9 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) 10 | nbands = 1; 11 | else 12 | nbands = 3; 13 | end 14 | 15 | ht = (size(pind,1)-1)/nbands; 16 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/wpyrLev.m: -------------------------------------------------------------------------------- 1 | % [LEV,IND] = wpyrLev(PYR,INDICES,LEVEL) 2 | % 3 | % Access a level from a separable QMF/wavelet pyramid. 4 | % Return as an SxB matrix, B = number of bands, S = total size of a band. 5 | % Also returns an Bx2 matrix containing dimensions of the subbands. 6 | 7 | % Eero Simoncelli, 6/96. 8 | 9 | function [lev,ind] = wpyrLev(pyr,pind,level) 10 | 11 | if ((pind(1,1) == 1) | (pind(1,2) ==1)) 12 | nbands = 1; 13 | else 14 | nbands = 3; 15 | end 16 | 17 | if ((level > wpyrHt(pind)) | (level < 1)) 18 | error(sprintf('Level number must be in the range [1, %d].', wpyrHt(pind))); 19 | end 20 | 21 | firstband = 1 + nbands*(level-1) 22 | firstind = 1; 23 | for l=1:firstband-1 24 | firstind = firstind + prod(pind(l,:)); 25 | end 26 | 27 | 28 | ind = pind(firstband:firstband+nbands-1,:); 29 | lev = pyr(firstind:firstind+sum(prod(ind'))-1); 30 | 31 | -------------------------------------------------------------------------------- /generate_datasets/statistical/matlab/matlabPyrTools/zconv2.m: -------------------------------------------------------------------------------- 1 | % RES = ZCONV2(MTX1, MTX2, CTR) 2 | % 3 | % Convolution of two matrices, with boundaries handled as if the larger mtx 4 | % lies in a sea of zeros. Result will be of size of LARGER vector. 5 | % 6 | % The origin of the smaller matrix is assumed to be its center. 7 | % For even dimensions, the origin is determined by the CTR (optional) 8 | % argument: 9 | % CTR origin 10 | % 0 DIM/2 (default) 11 | % 1 (DIM/2)+1 (behaves like conv2(mtx1,mtx2,'same')) 12 | 13 | % Eero Simoncelli, 2/97. 14 | 15 | function c = zconv2(a,b,ctr) 16 | 17 | if (exist('ctr') ~= 1) 18 | ctr = 0; 19 | end 20 | 21 | if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) 22 | large = a; small = b; 23 | elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) 24 | large = b; small = a; 25 | else 26 | error('one arg must be larger than the other in both dimensions!'); 27 | end 28 | 29 | ly = size(large,1); 30 | lx = size(large,2); 31 | sy = size(small,1); 32 | sx = size(small,2); 33 | 34 | %% These values are the index of the small mtx that falls on the 35 | %% border pixel of the large matrix when computing the first 36 | %% convolution response sample: 37 | sy2 = floor((sy+ctr+1)/2); 38 | sx2 = floor((sx+ctr+1)/2); 39 | 40 | clarge = conv2(large,small); 41 | c = clarge(sy2:ly+sy2-1, sx2:lx+sx2-1); 42 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/stylegan/__init__.py -------------------------------------------------------------------------------- /generate_datasets/stylegan/scripts/generate_dataset.sh: -------------------------------------------------------------------------------- 1 | GPU0=2 2 | GPU1=3 3 | GPU2=4 4 | GPU3=5 5 | 6 | PYTHONPATH=. 7 | 8 | python stylegan/generate_dataset.py --gpu $GPU0 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /mnt/localssd1/jwulff/datasets/stylegan-large-oriented-uniformbias0.2 & 9 | python stylegan/generate_dataset.py --gpu $GPU1 --startimg 325000 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /mnt/localssd1/jwulff/datasets/stylegan-large-oriented-uniformbias0.2 & 10 | python stylegan/generate_dataset.py --gpu $GPU2 --startimg 650000 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /mnt/localssd1/jwulff/datasets/stylegan-large-oriented-uniformbias0.2 & 11 | python stylegan/generate_dataset.py --gpu $GPU3 --startimg 975000 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /mnt/localssd1/jwulff/datasets/stylegan-large-oriented-uniformbias0.2 & 12 | 13 | wait 14 | 15 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/scripts/generate_dataset_high_res.sh: -------------------------------------------------------------------------------- 1 | GPU0=2 2 | GPU1=3 3 | GPU2=4 4 | GPU3=5 5 | 6 | PYTHONPATH=. 7 | 8 | python stylegan/generate_dataset.py --gpu $GPU0 --res 512 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /vision-nfs/torralba/env/mbaradad/movies_sfm/releases/noiselearning/raw_data/stylegan-oriented-512 & 9 | python stylegan/generate_dataset.py --gpu $GPU1 --res 512 --startimg 325000 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /vision-nfs/torralba/env/mbaradad/movies_sfm/releases/noiselearning/raw_data/stylegan-oriented-512 & 10 | python stylegan/generate_dataset.py --gpu $GPU2 --res 512 --startimg 650000 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /vision-nfs/torralba/env/mbaradad/movies_sfm/releases/noiselearning/raw_data/stylegan-oriented-512 & 11 | python stylegan/generate_dataset.py --gpu $GPU3 --res 512 --startimg 975000 --nimg 325000 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name /vision-nfs/torralba/env/mbaradad/movies_sfm/releases/noiselearning/raw_data/stylegan-oriented-512 & 12 | 13 | wait 14 | 15 | # python generate_dataset.py --nimg 1300 --network_type sparse_new --random_configuration 'chin-chout' --same_noise_map --bias_range 0.2 --name generated_datasets/stylegan-oriented -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. In '...' directory, run command '...' 16 | 2. See error (copy&paste full log, including exceptions and **stacktraces**). 17 | 18 | Please copy&paste text instead of screenshots for better searchability. 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. Linux Ubuntu 20.04, Windows 10] 28 | - PyTorch version (e.g., pytorch 1.7.1) 29 | - CUDA toolkit version (e.g., CUDA 11.0) 30 | - NVIDIA driver version 31 | - GPU [e.g., Titan V, RTX 3090] 32 | - Docker: did you use Docker? If yes, specify docker image URL (e.g., nvcr.io/nvidia/pytorch:20.12-py3) 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .cache/ 3 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | FROM nvcr.io/nvidia/pytorch:20.12-py3 10 | 11 | ENV PYTHONDONTWRITEBYTECODE 1 12 | ENV PYTHONUNBUFFERED 1 13 | 14 | RUN pip install imageio-ffmpeg==0.4.3 pyspng==0.1.0 15 | 16 | WORKDIR /workspace 17 | 18 | # Unset TORCH_CUDA_ARCH_LIST and exec. This makes pytorch run-time 19 | # extension builds significantly faster as we only compile for the 20 | # currently active GPU configuration. 21 | RUN (printf '#!/bin/bash\nunset TORCH_CUDA_ARCH_LIST\nexec \"$@\"\n' >> /entry.sh) && chmod a+x /entry.sh 22 | ENTRYPOINT ["/entry.sh"] 23 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | from .util import EasyDict, make_cache_dir_path 10 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib/tflib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | from . import autosummary 8 | from . import network 9 | from . import optimizer 10 | from . import tfutil 11 | from . import custom_ops 12 | 13 | from .tfutil import * 14 | from .network import Network 15 | 16 | from .optimizer import Optimizer 17 | 18 | from .custom_ops import get_plugin 19 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib/tflib/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | # empty 8 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_from_tf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | from . import submission 8 | 9 | from .submission.run_context import RunContext 10 | 11 | from .submission.submit import SubmitTarget 12 | from .submission.submit import PathType 13 | from .submission.submit import SubmitConfig 14 | from .submission.submit import submit_run 15 | from .submission.submit import get_path_from_template 16 | from .submission.submit import convert_path 17 | from .submission.submit import make_run_dir_path 18 | 19 | from .util import EasyDict 20 | 21 | submit_config: SubmitConfig = None # Package level variable for SubmitConfig which is only valid when inside the run function. 22 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_from_tf/submission/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | from . import run_context 8 | from . import submit 9 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_from_tf/submission/internal/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | from . import local 8 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_from_tf/submission/internal/local.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | class TargetOptions(): 8 | def __init__(self): 9 | self.do_not_copy_source_files = False 10 | 11 | class Target(): 12 | def __init__(self): 13 | pass 14 | 15 | def finalize_submit_config(self, submit_config, host_run_dir): 16 | print ('Local submit ', end='', flush=True) 17 | submit_config.run_dir = host_run_dir 18 | 19 | def submit(self, submit_config, host_run_dir): 20 | from ..submit import run_wrapper, convert_path 21 | print('- run_dir: %s' % convert_path(submit_config.run_dir), flush=True) 22 | return run_wrapper(submit_config) 23 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_from_tf/tflib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | from . import autosummary 8 | from . import network 9 | from . import optimizer 10 | from . import tfutil 11 | from . import custom_ops 12 | 13 | from .tfutil import * 14 | from .network import Network 15 | 16 | from .optimizer import Optimizer 17 | 18 | from .custom_ops import get_plugin 19 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_from_tf/tflib/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | # empty 8 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_old/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | from .util import EasyDict, make_cache_dir_path 10 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_old/tflib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | from . import autosummary 8 | from . import network 9 | from . import optimizer 10 | from . import tfutil 11 | from . import custom_ops 12 | 13 | from .tfutil import * 14 | from .network import Network 15 | 16 | from .optimizer import Optimizer 17 | 18 | from .custom_ops import get_plugin 19 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/dnnlib_old/tflib/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, NVIDIA Corporation. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://nvlabs.github.io/stylegan2/license.html 6 | 7 | # empty 8 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/docker_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 4 | # 5 | # NVIDIA CORPORATION and its licensors retain all intellectual property 6 | # and proprietary rights in and to this software, related documentation 7 | # and any modifications thereto. Any use, reproduction, disclosure or 8 | # distribution of this software and related documentation without an express 9 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 10 | 11 | set -e 12 | 13 | # Wrapper script for setting up `docker run` to properly 14 | # cache downloaded files, custom extension builds and 15 | # mount the source directory into the container and make it 16 | # run as non-root user. 17 | # 18 | # Use it like: 19 | # 20 | # ./docker_run.sh python generate.py --help 21 | # 22 | # To override the default `stylegan2ada:latest` image, run: 23 | # 24 | # IMAGE=my_image:v1.0 ./docker_run.sh python generate.py --help 25 | # 26 | 27 | rest=$@ 28 | 29 | IMAGE="${IMAGE:-sg2ada:latest}" 30 | 31 | CONTAINER_ID=$(docker inspect --format="{{.Id}}" ${IMAGE} 2> /dev/null) 32 | if [[ "${CONTAINER_ID}" ]]; then 33 | docker run --shm-size=2g --gpus all -it --rm -v `pwd`:/scratch --user $(id -u):$(id -g) \ 34 | --workdir=/scratch -e HOME=/scratch $IMAGE $@ 35 | else 36 | echo "Unknown container image: ${IMAGE}" 37 | exit 1 38 | fi 39 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/docs/stylegan2-ada-teaser-1024x252.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/stylegan/stylegan2-ada-pytorch/docs/stylegan2-ada-teaser-1024x252.png -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/docs/stylegan2-ada-training-curves.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/stylegan/stylegan2-ada-pytorch/docs/stylegan2-ada-training-curves.png -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/experiments/train_stylegan2.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/stylegan/stylegan2-ada-pytorch/experiments/train_stylegan2.sh -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/metrics/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | # empty 10 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/metrics/frechet_inception_distance.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | """Frechet Inception Distance (FID) from the paper 10 | "GANs trained by a two time-scale update rule converge to a local Nash 11 | equilibrium". Matches the original implementation by Heusel et al. at 12 | https://github.com/bioinf-jku/TTUR/blob/master/fid.py""" 13 | 14 | import numpy as np 15 | import scipy.linalg 16 | from . import metric_utils 17 | 18 | #---------------------------------------------------------------------------- 19 | 20 | def compute_fid(opts, max_real, num_gen): 21 | # Direct TorchScript translation of http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz 22 | detector_url = 'https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/metrics/inception-2015-12-05.pt' 23 | detector_kwargs = dict(return_features=True) # Return raw features before the softmax layer. 24 | 25 | mu_real, sigma_real = metric_utils.compute_feature_stats_for_dataset( 26 | opts=opts, detector_url=detector_url, detector_kwargs=detector_kwargs, 27 | rel_lo=0, rel_hi=0, capture_mean_cov=True, max_items=max_real).get_mean_cov() 28 | 29 | mu_gen, sigma_gen = metric_utils.compute_feature_stats_for_generator( 30 | opts=opts, detector_url=detector_url, detector_kwargs=detector_kwargs, 31 | rel_lo=0, rel_hi=1, capture_mean_cov=True, max_items=num_gen).get_mean_cov() 32 | 33 | if opts.rank != 0: 34 | return float('nan') 35 | 36 | m = np.square(mu_gen - mu_real).sum() 37 | s, _ = scipy.linalg.sqrtm(np.dot(sigma_gen, sigma_real), disp=False) # pylint: disable=no-member 38 | fid = np.real(m + np.trace(sigma_gen + sigma_real - s * 2)) 39 | return float(fid) 40 | 41 | #---------------------------------------------------------------------------- 42 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/metrics/inception_score.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | """Inception Score (IS) from the paper "Improved techniques for training 10 | GANs". Matches the original implementation by Salimans et al. at 11 | https://github.com/openai/improved-gan/blob/master/inception_score/model.py""" 12 | 13 | import numpy as np 14 | from . import metric_utils 15 | 16 | #---------------------------------------------------------------------------- 17 | 18 | def compute_is(opts, num_gen, num_splits): 19 | # Direct TorchScript translation of http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz 20 | detector_url = 'https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/metrics/inception-2015-12-05.pt' 21 | detector_kwargs = dict(no_output_bias=True) # Match the original implementation by not applying bias in the softmax layer. 22 | 23 | gen_probs = metric_utils.compute_feature_stats_for_generator( 24 | opts=opts, detector_url=detector_url, detector_kwargs=detector_kwargs, 25 | capture_all=True, max_items=num_gen).get_all() 26 | 27 | if opts.rank != 0: 28 | return float('nan'), float('nan') 29 | 30 | scores = [] 31 | for i in range(num_splits): 32 | part = gen_probs[i * num_gen // num_splits : (i + 1) * num_gen // num_splits] 33 | kl = part * (np.log(part) - np.log(np.mean(part, axis=0, keepdims=True))) 34 | kl = np.mean(np.sum(kl, axis=1)) 35 | scores.append(np.exp(kl)) 36 | return float(np.mean(scores)), float(np.std(scores)) 37 | 38 | #---------------------------------------------------------------------------- 39 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/slurm_sc/stylegan_imagenet.slurm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SBATCH -J train_imagenet_stylegan2_4GPU 3 | #SBATCH -o "$HOME/slurm_logs/train_imagenet_stylegan2_4GPU_%j" 4 | #SBATCH --mail-user=mbaradad@mit.edu 5 | #SBATCH --mail-type=ALL 6 | #SBATCH --gres=gpu:volta:1 7 | #SBATCH -N 1 8 | #SBATCH -n 40 9 | 10 | echo " Running on single nodes with 4 GPU" 11 | echo "" 12 | echo " Run started at:- " 13 | date 14 | 15 | STYLEGAN_PATH=/home/gridsan/mbaradad/projects/no_training_cnns/contrastive_image_models/image_generation/stylegan/stylegan2-ada-pytorch 16 | cd $STYLEGAN_PATH 17 | 18 | DATA_DIR=$IMAGENET_PATH/train 19 | 20 | OUT_DIR=imagenet_dir 21 | FOUND=false 22 | if [ -d $OUT_DIR ]; then 23 | CHECKPOINTS=($(ls --color=none -d $OUT_DIR/*/*.pkl | sort)) 24 | if [ ${#CHECKPOINTS[@]} -gt 0 ]; then 25 | 26 | echo $CHECKPOINTS 27 | 28 | echo "Number of checkpoints: ${#CHECKPOINTS[@]}" 29 | LATEST_CHECKPOINT=${CHECKPOINTS[${#CHECKPOINTS[@]}-1]} 30 | 31 | echo "Latest checkpoint: $LATEST_CHECKPOINT" 32 | 33 | LATEST_CHECKPOINT_KIMG=1 34 | FOUND=true 35 | 36 | arrIN=(${LATEST_CHECKPOINT//-/ }) 37 | RESUME_KIMG_TMP=${arrIN[${#arrIN[@]}-1]} 38 | 39 | arrIN=(${RESUME_KIMG_TMP//./ }) 40 | RESUME_KIMG=${arrIN[0]} 41 | 42 | fi 43 | fi 44 | 45 | if [ "$FOUND" = true ] ; then 46 | echo "Previous checkpoint found! Will restart training!" 47 | echo "Resuming from: $LATEST_CHECKPOINT" 48 | sleep 1s 49 | python train.py --outdir=$OUT_DIR --data=$DATA_DIR --gpus=4 --resume=$LATEST_CHECKPOINT --resume-kimg=$RESUME_KIMG 50 | 51 | else 52 | echo "Previous checkpoint not found!" 53 | python train.py --outdir=$OUT_DIR --data=$DATA_DIR --gpus=4 54 | fi 55 | 56 | 57 | echo "Run completed at:- " 58 | date 59 | 60 | # to excecute, run: 61 | # sbatch stylegan_imagenet.slurm -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/slurm_sc/test.slurm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/generate_datasets/stylegan/stylegan2-ada-pytorch/slurm_sc/test.slurm -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/torch_utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | # empty 10 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/torch_utils/ops/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | # empty 10 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/torch_utils/ops/bias_act.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | // 3 | // NVIDIA CORPORATION and its licensors retain all intellectual property 4 | // and proprietary rights in and to this software, related documentation 5 | // and any modifications thereto. Any use, reproduction, disclosure or 6 | // distribution of this software and related documentation without an express 7 | // license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | //------------------------------------------------------------------------ 10 | // CUDA kernel parameters. 11 | 12 | struct bias_act_kernel_params 13 | { 14 | const void* x; // [sizeX] 15 | const void* b; // [sizeB] or NULL 16 | const void* xref; // [sizeX] or NULL 17 | const void* yref; // [sizeX] or NULL 18 | const void* dy; // [sizeX] or NULL 19 | void* y; // [sizeX] 20 | 21 | int grad; 22 | int act; 23 | float alpha; 24 | float gain; 25 | float clamp; 26 | 27 | int sizeX; 28 | int sizeB; 29 | int stepB; 30 | int loopX; 31 | }; 32 | 33 | //------------------------------------------------------------------------ 34 | // CUDA kernel selection. 35 | 36 | template void* choose_bias_act_kernel(const bias_act_kernel_params& p); 37 | 38 | //------------------------------------------------------------------------ 39 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/torch_utils/ops/fma.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | """Fused multiply-add, with slightly faster gradients than `torch.addcmul()`.""" 10 | 11 | import torch 12 | 13 | #---------------------------------------------------------------------------- 14 | 15 | def fma(a, b, c): # => a * b + c 16 | return _FusedMultiplyAdd.apply(a, b, c) 17 | 18 | #---------------------------------------------------------------------------- 19 | 20 | class _FusedMultiplyAdd(torch.autograd.Function): # a * b + c 21 | @staticmethod 22 | def forward(ctx, a, b, c): # pylint: disable=arguments-differ 23 | out = torch.addcmul(c, a, b) 24 | ctx.save_for_backward(a, b) 25 | ctx.c_shape = c.shape 26 | return out 27 | 28 | @staticmethod 29 | def backward(ctx, dout): # pylint: disable=arguments-differ 30 | a, b = ctx.saved_tensors 31 | c_shape = ctx.c_shape 32 | da = None 33 | db = None 34 | dc = None 35 | 36 | if ctx.needs_input_grad[0]: 37 | da = _unbroadcast(dout * b, a.shape) 38 | 39 | if ctx.needs_input_grad[1]: 40 | db = _unbroadcast(dout * a, b.shape) 41 | 42 | if ctx.needs_input_grad[2]: 43 | dc = _unbroadcast(dout, c_shape) 44 | 45 | return da, db, dc 46 | 47 | #---------------------------------------------------------------------------- 48 | 49 | def _unbroadcast(x, shape): 50 | extra_dims = x.ndim - len(shape) 51 | assert extra_dims >= 0 52 | dim = [i for i in range(x.ndim) if x.shape[i] > 1 and (i < extra_dims or shape[i - extra_dims] == 1)] 53 | if len(dim): 54 | x = x.sum(dim=dim, keepdim=True) 55 | if extra_dims: 56 | x = x.reshape(-1, *x.shape[extra_dims+1:]) 57 | assert x.shape == shape 58 | return x 59 | 60 | #---------------------------------------------------------------------------- 61 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/torch_utils/ops/upfirdn2d.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | // 3 | // NVIDIA CORPORATION and its licensors retain all intellectual property 4 | // and proprietary rights in and to this software, related documentation 5 | // and any modifications thereto. Any use, reproduction, disclosure or 6 | // distribution of this software and related documentation without an express 7 | // license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | #include 10 | 11 | //------------------------------------------------------------------------ 12 | // CUDA kernel parameters. 13 | 14 | struct upfirdn2d_kernel_params 15 | { 16 | const void* x; 17 | const float* f; 18 | void* y; 19 | 20 | int2 up; 21 | int2 down; 22 | int2 pad0; 23 | int flip; 24 | float gain; 25 | 26 | int4 inSize; // [width, height, channel, batch] 27 | int4 inStride; 28 | int2 filterSize; // [width, height] 29 | int2 filterStride; 30 | int4 outSize; // [width, height, channel, batch] 31 | int4 outStride; 32 | int sizeMinor; 33 | int sizeMajor; 34 | 35 | int loopMinor; 36 | int loopMajor; 37 | int loopX; 38 | int launchMinor; 39 | int launchMajor; 40 | }; 41 | 42 | //------------------------------------------------------------------------ 43 | // CUDA kernel specialization. 44 | 45 | struct upfirdn2d_kernel_spec 46 | { 47 | void* kernel; 48 | int tileOutW; 49 | int tileOutH; 50 | int loopMinor; 51 | int loopX; 52 | }; 53 | 54 | //------------------------------------------------------------------------ 55 | // CUDA kernel selection. 56 | 57 | template upfirdn2d_kernel_spec choose_upfirdn2d_kernel(const upfirdn2d_kernel_params& p); 58 | 59 | //------------------------------------------------------------------------ 60 | -------------------------------------------------------------------------------- /generate_datasets/stylegan/stylegan2-ada-pytorch/training/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. 2 | # 3 | # NVIDIA CORPORATION and its licensors retain all intellectual property 4 | # and proprietary rights in and to this software, related documentation 5 | # and any modifications thereto. Any use, reproduction, disclosure or 6 | # distribution of this software and related documentation without an express 7 | # license agreement from NVIDIA CORPORATION is strictly prohibited. 8 | 9 | # empty 10 | -------------------------------------------------------------------------------- /moco/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/moco/__init__.py -------------------------------------------------------------------------------- /moco/detection/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## MoCo: Transferring to Detection 3 | 4 | The `train_net.py` script reproduces the object detection experiments on Pascal VOC and COCO. 5 | 6 | ### Instruction 7 | 8 | 1. Install [detectron2](https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md). 9 | 10 | 1. Convert a pre-trained MoCo model to detectron2's format: 11 | ``` 12 | python3 convert-pretrain-to-detectron2.py input.pth.tar output.pkl 13 | ``` 14 | 15 | 1. Put dataset under "./datasets" directory, 16 | following the [directory structure](https://github.com/facebookresearch/detectron2/tree/master/datasets) 17 | requried by detectron2. 18 | 19 | 1. Run training: 20 | ``` 21 | python train_net.py --config-file configs/pascal_voc_R_50_C4_24k_moco.yaml \ 22 | --num-gpus 8 MODEL.WEIGHTS ./output.pkl 23 | ``` 24 | 25 | ### Results 26 | 27 | Below are the results on Pascal VOC 2007 test, fine-tuned on 2007+2012 trainval for 24k iterations using Faster R-CNN with a R50-C4 backbone: 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 |
pretrainAP50APAP75
ImageNet-1M, supervised81.353.558.8
ImageNet-1M, MoCo v1, 200ep81.555.962.6
ImageNet-1M, MoCo v2, 200ep82.457.063.6
ImageNet-1M, MoCo v2, 800ep82.557.464.0
60 | 61 | ***Note:*** These results are means of 5 trials. Variation on Pascal VOC is large: the std of AP50, AP, AP75 is expected to be 0.2, 0.2, 0.4 in most cases. We recommend to run 5 trials and compute means. 62 | -------------------------------------------------------------------------------- /moco/detection/configs/Base-RCNN-C4-BN.yaml: -------------------------------------------------------------------------------- 1 | MODEL: 2 | META_ARCHITECTURE: "GeneralizedRCNN" 3 | RPN: 4 | PRE_NMS_TOPK_TEST: 6000 5 | POST_NMS_TOPK_TEST: 1000 6 | ROI_HEADS: 7 | NAME: "Res5ROIHeadsExtraNorm" 8 | BACKBONE: 9 | FREEZE_AT: 0 10 | RESNETS: 11 | NORM: "SyncBN" 12 | TEST: 13 | PRECISE_BN: 14 | ENABLED: True 15 | SOLVER: 16 | IMS_PER_BATCH: 16 17 | BASE_LR: 0.02 18 | -------------------------------------------------------------------------------- /moco/detection/configs/coco_R_50_C4_2x.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-C4-BN.yaml" 2 | MODEL: 3 | MASK_ON: True 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | INPUT: 6 | MIN_SIZE_TRAIN: (640, 672, 704, 736, 768, 800) 7 | MIN_SIZE_TEST: 800 8 | DATASETS: 9 | TRAIN: ("coco_2017_train",) 10 | TEST: ("coco_2017_val",) 11 | SOLVER: 12 | STEPS: (120000, 160000) 13 | MAX_ITER: 180000 14 | -------------------------------------------------------------------------------- /moco/detection/configs/coco_R_50_C4_2x_moco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "coco_R_50_C4_2x.yaml" 2 | MODEL: 3 | PIXEL_MEAN: [123.675, 116.280, 103.530] 4 | PIXEL_STD: [58.395, 57.120, 57.375] 5 | WEIGHTS: "See Instructions" 6 | RESNETS: 7 | STRIDE_IN_1X1: False 8 | INPUT: 9 | FORMAT: "RGB" 10 | -------------------------------------------------------------------------------- /moco/detection/configs/pascal_voc_R_50_C4_24k.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "Base-RCNN-C4-BN.yaml" 2 | MODEL: 3 | MASK_ON: False 4 | WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" 5 | ROI_HEADS: 6 | NUM_CLASSES: 20 7 | INPUT: 8 | MIN_SIZE_TRAIN: (480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800) 9 | MIN_SIZE_TEST: 800 10 | DATASETS: 11 | TRAIN: ('voc_2007_trainval', 'voc_2012_trainval') 12 | TEST: ('voc_2007_test',) 13 | SOLVER: 14 | STEPS: (18000, 22000) 15 | MAX_ITER: 24000 16 | WARMUP_ITERS: 100 17 | -------------------------------------------------------------------------------- /moco/detection/configs/pascal_voc_R_50_C4_24k_moco.yaml: -------------------------------------------------------------------------------- 1 | _BASE_: "pascal_voc_R_50_C4_24k.yaml" 2 | MODEL: 3 | PIXEL_MEAN: [123.675, 116.280, 103.530] 4 | PIXEL_STD: [58.395, 57.120, 57.375] 5 | WEIGHTS: "See Instructions" 6 | RESNETS: 7 | STRIDE_IN_1X1: False 8 | INPUT: 9 | FORMAT: "RGB" 10 | -------------------------------------------------------------------------------- /moco/detection/convert-pretrain-to-detectron2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 3 | 4 | import pickle as pkl 5 | import sys 6 | import torch 7 | 8 | if __name__ == "__main__": 9 | input = sys.argv[1] 10 | 11 | obj = torch.load(input, map_location="cpu") 12 | obj = obj["state_dict"] 13 | 14 | newmodel = {} 15 | for k, v in obj.items(): 16 | if not k.startswith("module.encoder_q."): 17 | continue 18 | old_k = k 19 | k = k.replace("module.encoder_q.", "") 20 | if "layer" not in k: 21 | k = "stem." + k 22 | for t in [1, 2, 3, 4]: 23 | k = k.replace("layer{}".format(t), "res{}".format(t + 1)) 24 | for t in [1, 2, 3]: 25 | k = k.replace("bn{}".format(t), "conv{}.norm".format(t)) 26 | k = k.replace("downsample.0", "shortcut") 27 | k = k.replace("downsample.1", "shortcut.norm") 28 | print(old_k, "->", k) 29 | newmodel[k] = v.numpy() 30 | 31 | res = {"model": newmodel, "__author__": "MOCO", "matching_heuristics": True} 32 | 33 | with open(sys.argv[2], "wb") as f: 34 | pkl.dump(res, f) 35 | -------------------------------------------------------------------------------- /moco/moco/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | -------------------------------------------------------------------------------- /moco/moco/loader.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | from PIL import ImageFilter 3 | import random 4 | 5 | 6 | class TwoCropsTransform: 7 | """Take two random crops of one image as the query and key.""" 8 | 9 | def __init__(self, base_transform): 10 | self.base_transform = base_transform 11 | 12 | def __call__(self, x): 13 | q = self.base_transform(x) 14 | k = self.base_transform(x) 15 | return [q, k] 16 | 17 | 18 | class GaussianBlur(object): 19 | """Gaussian blur augmentation in SimCLR https://arxiv.org/abs/2002.05709""" 20 | 21 | def __init__(self, sigma=[.1, 2.]): 22 | self.sigma = sigma 23 | 24 | def __call__(self, x): 25 | sigma = random.uniform(self.sigma[0], self.sigma[1]) 26 | x = x.filter(ImageFilter.GaussianBlur(radius=sigma)) 27 | return x 28 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | torch==1.6.0 2 | torchvision==0.7.0 3 | -------------------------------------------------------------------------------- /scripts/download_datasets/download_large_scale_datasets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p data 3 | mkdir -p data/large_scale 4 | 5 | datasets=('dead_leaves-mixed' \ 6 | 'feature_vis-dead_leaves' \ 7 | 'stat-spectrum_color_wmm' \ 8 | 'stylegan-oriented' \ 9 | ) 10 | 11 | for DATASET in ${datasets[@]} 12 | do 13 | echo "Downloading $DATASET" 14 | wget -O data/large_scale/$DATASET.zip http://data.csail.mit.edu/noiselearning/zipped_data/large_scale/$DATASET.zip 15 | yes | unzip data/large_scale/$DATASET.zip -d data/large_scale/$DATASET 16 | rm data/large_scale/$DATASET.zip 17 | done 18 | -------------------------------------------------------------------------------- /scripts/download_datasets/download_small_scale_datasets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p data 3 | mkdir -p data/small_scale 4 | 5 | datasets=('dead_leaves-squares' \ 6 | 'dead_leaves-oriented' \ 7 | 'dead_leaves-mixed' \ 8 | 'dead_leaves-textures' \ 9 | 10 | 'stat-spectrum' \ 11 | 'stat-wmm' \ 12 | 'stat-spectrum_color' \ 13 | 'stat-spectrum_color_wmm' \ 14 | 15 | 'stylegan-random' \ 16 | 'stylegan-highfreq' \ 17 | 'stylegan-sparse' \ 18 | 'stylegan-oriented' \ 19 | 20 | 'feature_vis-random' \ 21 | 'feature_vis-dead_leaves' \ 22 | ) 23 | 24 | for DATASET in ${datasets[@]} 25 | do 26 | echo "Downloading $DATASET" 27 | wget -O data/small_scale/$DATASET.zip http://data.csail.mit.edu/noiselearning/zipped_data/small_scale/$DATASET.zip 28 | yes | unzip data/small_scale/$DATASET.zip -d data/small_scale/$DATASET 29 | rm data/small_scale/$DATASET.zip 30 | done 31 | -------------------------------------------------------------------------------- /scripts/download_pretrained_models/download_large_scale_encoders.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p encoders 3 | mkdir -p encoders/small_scale 4 | 5 | datasets=('dead_leaves-mixed' \ 6 | 'feature_vis-dead_leaves' 7 | 'stat-spectrum_color_wmm' \ 8 | 'stylegan-oriented') 9 | 10 | for DATASET in ${datasets[@]} 11 | do 12 | echo "Downloading pretrained model for dataset $DATASET" 13 | mkdir -p encoders/large_scale/$DATASET 14 | wget -O encoders/large_scale/$DATASET/checkpoint_0199.pth.tar http://data.csail.mit.edu/noiselearning/encoders/large_scale/$DATASET/checkpoint_0199.pth.tar 15 | done 16 | 17 | DATASET=mixed-4 18 | echo "Downloading pretrained model for dataset $DATASET" 19 | mkdir -p encoders/large_scale/$DATASET 20 | wget -O encoders/large_scale/$DATASET/checkpoint_0799.pth.tar http://data.csail.mit.edu/noiselearning/encoders/large_scale/$DATASET/checkpoint_0799.pth.tar 21 | -------------------------------------------------------------------------------- /scripts/download_pretrained_models/download_small_scale_encoders.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p encoders 3 | mkdir -p encoders/small_scale 4 | 5 | datasets=('dead_leaves-squares' \ 6 | 'dead_leaves-oriented' \ 7 | 'dead_leaves-textures' \ 8 | 'dead_leaves-mixed' \ 9 | 10 | 'stat-spectrum' \ 11 | 'stat-wmm' \ 12 | 'stat-spectrum_color' \ 13 | 'stat-spectrum_color_wmm' \ 14 | 15 | 'stylegan-random' \ 16 | 'stylegan-highfreq' \ 17 | 'stylegan-sparse' \ 18 | 'stylegan-oriented' \ 19 | 20 | 'feature_vis-random' \ 21 | 'feature_vis-dead_leaves' \ 22 | ) 23 | 24 | for DATASET in ${datasets[@]} 25 | do 26 | echo "Downloading pretrained model for dataset $DATASET" 27 | mkdir -p encoders/small_scale/$DATASET 28 | wget -O encoders/small_scale/$DATASET/encoder.pth http://data.csail.mit.edu/noiselearning/encoders/small_scale/$DATASET/encoder.pth 29 | 30 | done 31 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the list of authors for copyright purposes. 2 | # 3 | # This does not necessarily list everyone who has contributed code, since in 4 | # some cases, their employer may be the copyright holder. To see the full list 5 | # of contributors, see the revision history in source control. 6 | 7 | Google LLC -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows [Google's Open Source Community 28 | Guidelines](https://opensource.google.com/conduct/). 29 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/scripts/generate_vtab_datasets/__init__.py -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/404.html: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: /404.html 3 | layout: default 4 | --- 5 | 6 | 19 | 20 |
21 |

404

22 | 23 |

Page not found :(

24 |

The requested page could not be found.

25 |
26 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | # This is the default theme for new Jekyll sites. You may change this to anything you like. 3 | gem "minima", "~> 2.5" 4 | # Use GitHub pages and resolve the Jekyll version. 5 | gem "github-pages", group: :jekyll_plugins 6 | # If you have any plugins, put them here! 7 | group :jekyll_plugins do 8 | end 9 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/_config.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Jekyll! 2 | # 3 | # This config file is meant for settings that affect your whole blog, values 4 | # which you are expected to set up once and rarely edit after that. If you find 5 | # yourself editing this file very often, consider using Jekyll's data files 6 | # feature for the data you need to update frequently. 7 | # 8 | # For technical reasons, this file is *NOT* reloaded automatically when you use 9 | # 'bundle exec jekyll serve'. If you change this file, please restart the server process. 10 | # 11 | # If you need help with YAML syntax, here are some quick references for you: 12 | # https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml 13 | # https://learnxinyminutes.com/docs/yaml/ 14 | # 15 | # Site settings 16 | # These are used to personalize your new site. If you look in the HTML files, 17 | # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. 18 | # You can create any custom variable you would like, and they will be accessible 19 | # in the templates via {{ site.myvariable }}. 20 | 21 | title: Visual Task Adaptation Benchmark 22 | email: vtab@google.com 23 | author: "" # When author is not present, minima template displays title twice. 24 | description: >- # this means to ignore newlines until "baseurl:" 25 | The Visual Task Adaptation Benchmark (VTAB) contains 19 vision tasks. 26 | Algorithms must solve each task with limited downstream data, and without 27 | task-specific logic. 28 | baseurl: "/task_adaptation" # the subpath of your site, e.g. /blog 29 | url: "https://google-research.github.io/" # the base hostname & protocol for your site, e.g. http://example.com 30 | 31 | # Build settings 32 | theme: minima 33 | 34 | # Exclude from processing. 35 | # The following items will not be processed, by default. 36 | # Any item listed under the `exclude:` key here will be automatically added to 37 | # the internal "default list". 38 | # 39 | # Excluded items can be processed by explicitly listing the directories or 40 | # their entries' file path in the `include:` list. 41 | # 42 | # exclude: 43 | # - .sass-cache/ 44 | # - .jekyll-cache/ 45 | # - gemfiles/ 46 | # - Gemfile 47 | # - Gemfile.lock 48 | # - node_modules/ 49 | # - vendor/bundle/ 50 | # - vendor/cache/ 51 | # - vendor/gems/ 52 | # - vendor/ruby/ 53 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/_includes/abstract.md: -------------------------------------------------------------------------------- 1 | The Visual Task Adaptation Benchmark (VTAB) is a diverse and challenging suite of tasks, 2 | designed to evaluate general visual representations. 3 | 4 | VTAB defines a good general visual representation as one that yields good performance on *unseen* tasks, 5 | when trained on limited task-specific data. 6 | VTAB places no restrictions on how the representations are used, for example, frozen feature extraction, 7 | fine-tuning, and other forms of transfer to the evaluation tasks are permitted. 8 | Similarly, representations may be pre-trained on any data, VTAB permits supervised, unsupervised, or other pre-training strategy. 9 | There is one constraint: *the evaluation datasets must not be used during pre-training*. 10 | This constraint is designed to mitigate overfitting to the evaluation tasks. 11 | 12 | The benchmark consists of 19 tasks, drawn from a variety of domains, and with various semantics. 13 | All tasks are framed as classification problems to facilitate a consistent API for pre-trained models. 14 | Algorithms should not contain any task-dependent logic, for example, 15 | the same hyperparameter sweep should be used for all tasks. 16 | VTAB may also be used to evaluate techniques, other than representation learning, 17 | that improve performance across a variety of tasks: such as architectures, pre-processing functions, or optimizers. 18 | 19 | The page tracks the performance of algorithms published using VTAB. 20 | To highlight a result to the VTAB admins, contact vtab@google.com. 21 | 22 | VTAB provides: 23 | * [Code](https://github.com/google-research/task_adaptation) to run the benchmark. 24 | * [A repository](https://tfhub.dev/vtab) of pre-trained models, evaluated on the benchmark. 25 | * A public leaderboard to track progress. 26 | * *Coming Soon*: A mechanism to submit TF Hub modules for automatic evaluation. 27 | 28 | 29 | [Paper](https://arxiv.org/abs/1910.04867)
30 | [GitHub](https://github.com/google-research/task_adaptation)
31 | [Models on TF Hub](https://tfhub.dev/vtab) 32 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/benchmark.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: page 3 | title: Leaderboard 4 | --- 5 | 6 | 7 | Detailed Leaderboard 8 | 9 | Mean scores across all 19 tasks. 10 | The two scenarios are: 1000 examples per task, and full datasets. 11 | All cells report top-1 accuracy. 12 |
13 |
14 | 15 |
16 |

Breakdown Across Tasks

17 |

18 | Select datasets to include: 19 |

20 |
21 |

1000 Training Examples per task

22 |
23 |

Full Training Sets

24 |
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/benchmark_data.css: -------------------------------------------------------------------------------- 1 | .benchmark { 2 | margin-bottom: 2em; 3 | } 4 | 5 | .benchmark.full, 6 | .benchmark.sampled { 7 | left: 50%; 8 | margin-left: calc(-50vw + 80px); 9 | overflow: auto; 10 | position: relative; 11 | width: calc(100vw - 160px); 12 | } 13 | 14 | .benchmark table { 15 | table-layout: fixed; 16 | word-break: break-all; 17 | margin: 0; 18 | } 19 | 20 | .benchmark tbody tr:hover { 21 | background-color: rgba(255, 187, 0, 0.5); 22 | } 23 | 24 | .benchmark td.model { 25 | white-space:nowrap; 26 | } 27 | 28 | .benchmark th { 29 | font-size: 0.8em; 30 | width: 32px; 31 | overflow: hidden; 32 | text-overflow: ellipsis; 33 | white-space: nowrap; 34 | } 35 | 36 | .benchmark th:first-child { 37 | width: 100px; 38 | } 39 | 40 | .benchmark th:not(:first-child) { 41 | cursor: pointer; 42 | } 43 | 44 | .benchmark th.sort-key:not(:first-child) { 45 | background-color: rgba(0, 0, 0, 0.2); 46 | text-decoration: underline; 47 | } 48 | 49 | .datasets { 50 | margin-bottom: 2em; 51 | } 52 | 53 | h2 { 54 | font-size: 1.3em; 55 | } 56 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: home 3 | --- 4 | 5 | 6 | {% capture abstract %}{% include abstract.md %}{% endcapture %} 7 | {{ abstract | markdownify }} 8 | 9 |

Leaderboard summary

10 |
11 | [Detailed leaderboard](benchmark)
12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/download_and_dump_all_vtab_datasets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | datasets=('caltech101' \ 3 | 'cifar(num_classes=100)' \ 4 | 'clevr(task="closest_object_distance")' \ 5 | 'clevr(task="count_all")' \ 6 | 'diabetic_retinopathy(config="btgraham-300")'\ 7 | 'dmlab' \ 8 | 'dsprites(predicted_attribute="label_x_position",num_classes=16)' \ 9 | 'dsprites(predicted_attribute="label_orientation",num_classes=16)' \ 10 | 'dtd' \ 11 | 'eurosat' \ 12 | 'kitti(task="closest_vehicle_distance")' \ 13 | 'oxford_iiit_pet' \ 14 | 'oxford_flowers102' \ 15 | 'patch_camelyon' \ 16 | 'resisc45' \ 17 | 'smallnorb(predicted_attribute="label_azimuth")' \ 18 | 'smallnorb(predicted_attribute="label_elevation")' \ 19 | 'sun397_ours'\ 20 | 'svhn' 21 | ) 22 | 23 | 24 | DATA_DIR=/tmp 25 | DUMP_PATH=../../vtab_datasets 26 | 27 | for DATASET in "${datasets[@]}" 28 | do 29 | echo "Processing dataset $DATASET" 30 | python dump_datasets.py --dataset \"$DATASET\" --data_dir $DATA_DIR, --dump_datasets_path $DUMP_PATH 31 | # process in parallel 32 | # python dump_datasets.py --dataset \"$DATASET\" & 33 | done 34 | wait 35 | 36 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/missing_datasets/test_default_model_missing_datasets_0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # coding=utf-8 3 | # Copyright 2019 Google LLC. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # This script fine tunes a given Hub model on all tasks from the VTAB benchmark. 18 | # It expects two parameters: 19 | # 1. Hub model path or link. 20 | # 2. Work directory path. 21 | 22 | datasets=('sun397') 23 | 24 | GPU=3 25 | HUB_MODEL=https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3 26 | HUB_MODEL_SIGNATURE=image_feature_vector 27 | WORK_DIR=vtab_eval/results/test_default_model 28 | FINETUNE_LAYER=resnet_v2_50/global_pool 29 | TRAIN_LINEAR_ONLY=False 30 | 31 | mkdir -p $WORK_DIR 32 | 33 | LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH 34 | 35 | adapt_and_eval(){ 36 | gpu=$1 37 | dataset=$2 38 | hub=$3 39 | hub_module_signature=$4 40 | workdir=$5 41 | finetune_layer=$6 42 | train_linear_only=$7 43 | python vtab_eval/task_adaptation/adapt_and_eval.py \ 44 | --hub_module $hub \ 45 | --hub_module_signature $hub_module_signature \ 46 | --finetune_layer $finetune_layer \ 47 | --train_linear_only $train_linear_only \ 48 | --work_dir $workdir/$dataset \ 49 | --dataset $dataset \ 50 | --train_examples 1000 \ 51 | --batch_size 64 \ 52 | --batch_size_eval 10 \ 53 | --initial_learning_rate 0.01 \ 54 | --decay_steps 300,600,900 \ 55 | --input_range 0.0,1.0 \ 56 | --max_steps 1000 \ 57 | --warmup_steps 80 \ 58 | --save_checkpoint_steps 1000 \ 59 | --gpu $gpu 60 | } 61 | 62 | for dataset in "${datasets[@]}" 63 | do 64 | adapt_and_eval $GPU $dataset $HUB_MODEL $HUB_MODEL_SIGNATURE $WORK_DIR $FINETUNE_LAYER $TRAIN_LINEAR_ONLY 65 | done 66 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/pretrained_resnet_all.sh: -------------------------------------------------------------------------------- 1 | ./vtab_eval/experiments/test_model.sh resnet50_pretrained True False 2 2 | #./vtab_eval/experiments/test_model.sh resnet50_pretrained True True 2 3 | #./vtab_eval/experiments/test_model.sh resnet50_pretrained False False 2 4 | #./vtab_eval/experiments/test_model.sh resnet50_pretrained False True 2 -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/pretrained_smallalexnet.sh: -------------------------------------------------------------------------------- 1 | ./vtab_eval/experiments/test_model.sh small_alexnet_places365_RGB True False 3 2 | ./vtab_eval/experiments/test_model.sh small_alexnet_places365_RGB True True 3 3 | 4 | ./vtab_eval/experiments/test_model.sh small_alexnet_imagenet_RGB True False 3 5 | ./vtab_eval/experiments/test_model.sh small_alexnet_imagenet_RGB True True 3 6 | 7 | ./vtab_eval/experiments/test_model.sh small_alexnet_my_dead_leaves_mixed_RGB True False 3 8 | ./vtab_eval/experiments/test_model.sh small_alexnet_my_dead_leaves_mixed_RGB True True 3 -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/pretrained_vgg.sh: -------------------------------------------------------------------------------- 1 | ./vtab_eval/experiments/test_model.sh vgg11_places365_RGB True False 2 2 | ./vtab_eval/experiments/test_model.sh vgg11_places365_RGB True True 2 3 | 4 | ./vtab_eval/experiments/test_model.sh vgg11_imagenet_RGB True False 2 5 | ./vtab_eval/experiments/test_model.sh vgg11_imagenet_RGB True True 2 6 | 7 | ./vtab_eval/experiments/test_model.sh vgg11_my_dead_leaves_mixed_RGB True False 2 8 | ./vtab_eval/experiments/test_model.sh vgg11_my_dead_leaves_mixed_RGB True True 2 -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/resnet_moco_pretrained.sh: -------------------------------------------------------------------------------- 1 | #MODEL=$1 2 | #TRAIN_LINEAR_ONLY=$2 3 | #FULL=$3 4 | #GPU=$4 5 | 6 | ./vtab_eval/experiments/test_model.sh moco_v2_pretrained_200 True False 3 7 | 8 | #./vtab_eval/experiments/test_model.sh moco_v2_pretrained_200 True True 3 9 | #./vtab_eval/experiments/test_model.sh moco_v2_pretrained_200 False False 3 10 | #./vtab_eval/experiments/test_model.sh moco_v2_pretrained_200 False True 3 -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/resnet_random_all.sh: -------------------------------------------------------------------------------- 1 | #MODEL=$1 2 | #TRAIN_LINEAR_ONLY=$2 3 | #FULL=$3 4 | #GPU=$4 5 | 6 | ./vtab_eval/experiments/test_model.sh resnet50_random True False 1 7 | 8 | #./vtab_eval/experiments/test_model.sh resnet50_random True True 1 9 | #./vtab_eval/experiments/test_model.sh resnet50_random False False 1 10 | #./vtab_eval/experiments/test_model.sh resnet50_random False True 1 -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/experiments/test_resnet_moco.sh: -------------------------------------------------------------------------------- 1 | #MODEL=$1 2 | #TRAIN_LINEAR_ONLY=$2 3 | #FULL=$3 4 | #GPU=$4 5 | 6 | ./vtab_eval/experiments/test_model.sh moco_v2_imagenet_pytorch True False 0 7 | ./vtab_eval/experiments/test_model.sh moco_v2_my_dead_leaves_mixed_large_res_256_RGB True False 0 8 | ./vtab_eval/experiments/test_model.sh resnet50_random True False 0 -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/port_model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/scripts/generate_vtab_datasets/port_model/__init__.py -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/port_model/dog.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mbaradad/learning_with_noise/a31abe38eac2bc9071c639dd925e7bfa7bf8dde9/scripts/generate_vtab_datasets/port_model/dog.jpeg -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/port_model/port_utils.py: -------------------------------------------------------------------------------- 1 | from tensorflow.python.eager import context 2 | import tensorflow as tf 3 | 4 | def load_variable(model_dir, name): 5 | with context.graph_mode(): 6 | return tf.train.load_variable(model_dir, name) 7 | 8 | 9 | def get_variables(model_dir): 10 | with context.graph_mode(): 11 | return [name for name, _ in tf.train.list_variables(model_dir)] -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/setup.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2019 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """Install task_adaptation.""" 17 | 18 | from setuptools import find_packages 19 | from setuptools import setup 20 | 21 | setup( 22 | name='task_adaptation', 23 | version='0.1', 24 | description=( 25 | 'Task Adaptation - a package for evaluating visual final_models.'), 26 | author='Google LLC', 27 | author_email='task-adaptation@google.com', 28 | url='https://github.com/google/task_adaptation', 29 | license='Apache 2.0', 30 | packages=find_packages(), 31 | package_data={}, 32 | scripts=['task_adaptation/adapt_and_eval.py'], 33 | install_requires=[ 34 | 'absl-py', 35 | 'numpy', 36 | 'six', 37 | 'mock', 38 | 'tensorflow', 39 | 'tfds-nightly', 40 | 'tensorflow-hub', 41 | 'tensorflow_addons', 42 | ], 43 | classifiers=[ 44 | 'Development Status :: 4 - Beta', 45 | 'Intended Audience :: Developers', 46 | 'Intended Audience :: Science/Research', 47 | 'License :: OSI Approved :: Apache Software License', 48 | 'Topic :: Scientific/Engineering :: Artificial Intelligence', 49 | ], 50 | keywords=('tensorflow machine transfer learning ' 51 | 'visual task adaptation benchmark vtab computer vision'), 52 | ) 53 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/task_adaptation/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2019 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/task_adaptation/data_loader_test.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2019 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """Tests for data_loader.""" 17 | 18 | from __future__ import absolute_import 19 | from __future__ import division 20 | from __future__ import print_function 21 | 22 | from absl.testing import absltest 23 | from task_adaptation import data_loader 24 | from task_adaptation import test_utils 25 | 26 | import tensorflow.compat.v1 as tf 27 | 28 | 29 | class DataLoaderTest(absltest.TestCase): 30 | 31 | def test_build_data_pipeline(self): 32 | input_fn = data_loader.build_data_pipeline(test_utils.get_data_params(), 33 | mode="eval") 34 | data = input_fn({"batch_size": 32}).make_one_shot_iterator().get_next() 35 | self.assertIsInstance(data["image"], tf.Tensor) 36 | self.assertIsInstance(data["label"], tf.Tensor) 37 | 38 | 39 | if __name__ == "__main__": 40 | absltest.main() 41 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/task_adaptation/loop_test.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2019 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """Tests for loop.py.""" 17 | 18 | from __future__ import absolute_import 19 | from __future__ import division 20 | from __future__ import print_function 21 | 22 | import os 23 | import tempfile 24 | 25 | from absl.testing import absltest 26 | from task_adaptation import loop 27 | from task_adaptation import test_utils 28 | import tensorflow.compat.v1 as tf 29 | 30 | 31 | class LoopTest(tf.test.TestCase): 32 | 33 | def test_run_training_loop(self): 34 | module_path = os.path.join(self.get_temp_dir(), "module") 35 | test_utils.create_dummy_hub_model(module_path, num_outputs=10) 36 | tmp_dir = tempfile.mkdtemp() 37 | loop.run_training_loop( 38 | hub_module=module_path, 39 | hub_module_signature=None, 40 | work_dir=tmp_dir, 41 | tpu_name=None, 42 | save_checkpoints_steps=10, 43 | optimization_params=test_utils.get_optimization_params(), 44 | data_params=test_utils.get_data_params()) 45 | 46 | self.assertNotEmpty([f for f in os.listdir(tmp_dir) 47 | if f.startswith("model.ckpt")]) 48 | 49 | 50 | if __name__ == "__main__": 51 | absltest.main() 52 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/task_adaptation/trainer_test.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2019 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """Tests for the trainer module.""" 17 | 18 | from __future__ import absolute_import 19 | from __future__ import division 20 | from __future__ import print_function 21 | 22 | from absl.testing import absltest 23 | 24 | import task_adaptation.trainer as trainer 25 | 26 | import tensorflow.compat.v1 as tf 27 | 28 | 29 | class ModelTest(absltest.TestCase): 30 | 31 | def test_get_train_op(self): 32 | dummy_net = tf.Variable(0.0) + 0.0 33 | trainer.get_train_op(dummy_net, 34 | initial_learning_rate=0.01, 35 | momentum=0.9, 36 | lr_decay_factor=0.1, 37 | decay_steps=(1000, 2000, 3000), 38 | warmup_steps=0) 39 | 40 | -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/tests/count_number_of_dumped_images.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append('.') 3 | sys.path.append('..') 4 | sys.path.append('../..') 5 | 6 | from my_python_utils.common_utils import * 7 | 8 | dumped_datasets_path='/data/vision/torralba/scratch/mbaradad/vtab_datasets' 9 | datasets = listdir(dumped_datasets_path, prepend_folder=True) 10 | 11 | completed_datasets = listdir(dumped_datasets_path + '/completed_datasets_list', prepend_folder=False) 12 | completed_datasets.sort() 13 | 14 | for dataset in completed_datasets: 15 | print("Testing number of files for dataset: " + dataset) 16 | for split in ['train', 'val']: 17 | dataset_split_path = '{}/{}/{}'.format(dumped_datasets_path, dataset, split) 18 | files = find_all_files_recursively(dataset_split_path) 19 | print("{}: {}".format(split.capitalize(), len(files))) -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/tests/split_rsics.py: -------------------------------------------------------------------------------- 1 | from my_python_utils.common_utils import * 2 | 3 | import os 4 | 5 | rsics_manual_path = '/data/vision/torralba/movies_sfm/home/tensorflow_datasets/downloads/manual/NWPU-RESISC45' 6 | for full_filename in tqdm(sorted(listdir(rsics_manual_path, prepend_folder=True, type='file', extension='.jpg'))): 7 | filename = os.path.basename(full_filename) 8 | photo_name = filename.split('_')[-1] 9 | object_type = '_'.join(filename.split('_')[:-1]) 10 | folder = rsics_manual_path + '/' + object_type 11 | os.makedirs(folder, exist_ok=True) 12 | shutil.move(full_filename, folder + '/' + photo_name) -------------------------------------------------------------------------------- /scripts/generate_vtab_datasets/tests/test_sun397.py: -------------------------------------------------------------------------------- 1 | import resource 2 | 3 | # to avoid ancdata error for too many open files, same as ulimit in console 4 | # maybe not necessary, but doesn't hurt 5 | resource.setrlimit(resource.RLIMIT_NOFILE, (131072, 131072)) 6 | 7 | from modified_builders.sun397_ours import Sun397_ours 8 | 9 | builder_kwargs = {'config': 'tfds', 10 | 'version': '4.*.*', 11 | 'data_dir': '/data/vision/torralba/scratch/mbaradad/tensorflow_datasets_test'} 12 | dataset_builder = Sun397_ours(**builder_kwargs) 13 | 14 | dataset_builder.download_and_prepare() 15 | 16 | -------------------------------------------------------------------------------- /scripts/train_align_uniform/cat_linear_eval_imagenet100.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # imagenet_100 path ours: 4 | # /data/vision/torralba/datasets/imagenet100 5 | 6 | IMAGENET_PATH=$1 7 | GPU_0=$2 8 | 9 | re='^[0-9]+$' 10 | if ! [[ $GPU_0 =~ $re ]] ; then 11 | echo "error: No GPU provided as argument" >&2; exit 1 12 | fi 13 | 14 | datasets=('dead_leaves-squares' \ 15 | 'dead_leaves-oriented' \ 16 | 'dead_leaves-textures' \ 17 | 'dead_leaves-mixed' \ 18 | 19 | 'stat-spectrum' \ 20 | 'stat-wmm' \ 21 | 'stat-spectrum_color' \ 22 | 'stat-spectrum_color_wmm' \ 23 | 24 | 'stylegan-random' \ 25 | 'stylegan-highfreq' \ 26 | 'stylegan-sparse' \ 27 | 'stylegan-oriented' \ 28 | 29 | 'feature_vis-random' \ 30 | 'feature_vis-dead_leaves' \ 31 | ) 32 | 33 | # Imagenet100 34 | for MODEL in "${models[@]}"; do 35 | ACCURACY=$( tail -n 1 lincls_imagenet/small_scale/$DATASET/log_eval.txt ) 36 | echo "$DATASET: $ACCURACY" 37 | done -------------------------------------------------------------------------------- /scripts/train_align_uniform/linear_eval_imagenet100.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # imagenet_100 path ours: 4 | # /data/vision/torralba/datasets/imagenet100 5 | 6 | mkdir -p encoders 7 | mkdir -p encoders/small_scale 8 | 9 | IMAGENET_PATH=$1 10 | GPU_0=$2 11 | 12 | re='^[0-9]+$' 13 | if ! [[ $GPU_0 =~ $re ]] ; then 14 | echo "error: No GPU provided as argument" >&2; exit 1 15 | fi 16 | 17 | datasets=('dead_leaves-squares' \ 18 | 'dead_leaves-oriented' \ 19 | 'dead_leaves-textures' \ 20 | 'dead_leaves-mixed' \ 21 | 22 | 'stat-spectrum' \ 23 | 'stat-wmm' \ 24 | 'stat-spectrum_color' \ 25 | 'stat-spectrum_color_wmm' \ 26 | 27 | 'stylegan-random' \ 28 | 'stylegan-highfreq' \ 29 | 'stylegan-sparse' \ 30 | 'stylegan-oriented' \ 31 | 32 | 'feature_vis-random' \ 33 | 'feature_vis-dead_leaves' \ 34 | ) 35 | 36 | # Imagenet100 37 | for DATASET in "${datasets[@]}"; do 38 | if [ ! -f lincls_imagenet/small_scale/$DATASET/val_acc.txt ]; then 39 | echo "Running Imagenet100 for $DATASET" 40 | CUDA_VISIBLE_DEVICES=$GPU_0 python align_uniform/linear_eval_imagenet100.py -d $DATASET --imagenet100_path $IMAGENET_PATH 41 | else 42 | echo "Imagenet100 linear evaluation already computed for $DATASET, main will not run again!" 43 | fi 44 | done -------------------------------------------------------------------------------- /scripts/train_align_uniform/linear_eval_vtab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # imagenet_100 path ours: 4 | # /data/vision/torralba/datasets/imagenet100 5 | 6 | mkdir -p encoders 7 | mkdir -p encoders/small_scale 8 | 9 | IMAGENET_PATH=$1 10 | GPU_0=$2 11 | 12 | re='^[0-9]+$' 13 | if ! [[ $GPU_0 =~ $re ]] ; then 14 | echo "error: No GPU provided as argument" >&2; exit 1 15 | fi 16 | 17 | datasets=('dead_leaves-squares' \ 18 | 'dead_leaves-oriented' \ 19 | 'dead_leaves-textures' \ 20 | 'dead_leaves-mixed' \ 21 | 22 | 'stat-spectrum' \ 23 | 'stat-wmm' \ 24 | 'stat-spectrum_color' \ 25 | 'stat-spectrum_color_wmm' \ 26 | 27 | 'stylegan-random' \ 28 | 'stylegan-highfreq' \ 29 | 'stylegan-sparse' \ 30 | 'stylegan-oriented' \ 31 | 32 | 'feature_vis-random' \ 33 | 'feature_vis-dead_leaves' \ 34 | ) 35 | 36 | for VTAB_DATASET in "${vtab_datasets[@]}"; do 37 | for DATASET in "${datasets[@]}"; do 38 | if [ ! -f lincls_imagenet/small_alexnet/$DATASET/val_acc.txt ]; then 39 | echo "Running Imagenet100 for $DATASET" 40 | CUDA_VISIBLE_DEVICES=$GPU_0 python align_uniform/linear_eval_imagenet100.py -d $DATASET --imagenet100_path $IMAGENET_PATH 41 | else 42 | echo "Imagenet100 linear evaluation already computed for $DATASET, main will not run again!" 43 | fi 44 | done -------------------------------------------------------------------------------- /scripts/train_align_uniform/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p encoders 3 | mkdir -p encoders/small_scale 4 | 5 | GPU_0=$1 6 | GPU_1=$2 7 | 8 | re='^[0-9]+$' 9 | if ! [[ $GPU_0 =~ $re ]] ; then 10 | echo "error: No GPU provided as argument" >&2; exit 1 11 | fi 12 | if ! [[ $GPU_1 =~ $re ]] ; then 13 | echo "error: No GPU provided as argument" >&2; exit 1 14 | fi 15 | 16 | datasets=('dead_leaves-squares' \ 17 | 'dead_leaves-oriented' \ 18 | 'dead_leaves-textures' \ 19 | 'dead_leaves-mixed' \ 20 | 21 | 'stat-spectrum' \ 22 | 'stat-wmm' \ 23 | 'stat-spectrum_color' \ 24 | 'stat-spectrum_color_wmm' \ 25 | 26 | 'stylegan-random' \ 27 | 'stylegan-highfreq' \ 28 | 'stylegan-sparse' \ 29 | 'stylegan-oriented' \ 30 | 31 | 'feature_vis-random' \ 32 | 'feature_vis-dead_leaves' \ 33 | ) 34 | 35 | for DATASET in ${datasets[@]} 36 | do 37 | 38 | if [ ! -f encoders/small_scale/$DATASET/encoder.pth ]; then 39 | echo "Training encoder for dataset $DATASET" 40 | python align_uniform/main.py --imagefolder data/small_scale/$DATASET --result encoders/small_scale/$DATASET --gpus $GPU_0 $GPU_1 41 | else 42 | echo "Encoder already found for $DATASET, main will not run again!" 43 | fi 44 | done 45 | -------------------------------------------------------------------------------- /scripts/train_moco/train_main_and_linear_moco.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | EXP_NAME=$1 3 | IMAGENET_FOLDER=$2 4 | 5 | RESULTS_FOLDER=encoders/large_scale/$EXP_NAME 6 | 7 | echo "Computing main moco!" 8 | python moco/main_moco.py --batch-size 256 --mlp --moco-t 0.2 --aug-plus --cos --multiprocessing-distributed --world-size 1 --rank 0 --dist-url tcp://localhost:10043 \ 9 | --epochs 200 --restart-latest --result-folder $RESULTS_FOLDER \ 10 | --dataset_type imagefolder --log-wandb True --workers 65 \ 11 | data/large_scale/$EXP_NAME 12 | 13 | echo "Computing linear eval!" 14 | python moco/main_lincls.py -a resnet50 --batch-size 256 \ 15 | --dist-url 'tcp://localhost:10043' --multiprocessing-distributed --world-size 1 --rank 0 --lr 30.0 \ 16 | --pretrained $RESULTS_FOLDER/checkpoint_0199.pth.tar \ 17 | --restart-latest \ 18 | --result-folder $RESULTS_FOLDER/main_lincls/epoch_199 \ 19 | $IMAGENET_FOLDER --------------------------------------------------------------------------------