[
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2016 Richard Zhang\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "## Split-Brain Autoencoders: Unsupervised Learning by Cross-Channel Prediction [[Project Page]](http://richzhang.github.io/splitbrainauto/) ##\n[Richard Zhang](https://richzhang.github.io/), [Phillip Isola](http://web.mit.edu/phillipi/), [Alexei A. Efros](http://www.eecs.berkeley.edu/~efros/). In CVPR, 2017. (hosted on [ArXiv](https://arxiv.org/abs/1611.09842))\n\n<img src=\"http://richzhang.github.io/index_files/cvpr2017_splitbrain.png\" height=\"180\" />\n\n### Overview ###\nThis repository contains a pre-trained Split-Brain Autoencoder network. The network achieves state-of-the-art results on several large-scale unsupervised representation learning benchmarks.\n\n### Clone this repository ###\nClone the master branch of the respository using `git clone -b master --single-branch https://github.com/richzhang/splitbrainauto.git`\n\n### Dependencies ###\nThis code requires a working installation of [Caffe](http://caffe.berkeleyvision.org/). For guidelines and help with installation of Caffe, consult the [installation guide](http://caffe.berkeleyvision.org/) and [Caffe users group](https://groups.google.com/forum/#!forum/caffe-users).\n\n### Test-Time Usage ###\n**(1)** Run `./resources/fetch_models.sh`. This will load model `model_splitbrainauto_clcl.caffemodel`. It will also load model `model_splitbrainauto_clcl_rs.caffemodel`, which is the model with the rescaling method from [Kr&auml;henb&uuml;hl et al. ICLR 2016](https://github.com/philkr/magic_init) applied. The rescaling method has been shown to improve fine-tuning performance in some models, and we use it for the PASCAL tests in Table 4 in the paper. Alternatively, download the models from [here](https://people.eecs.berkeley.edu/~rich.zhang/projects/2017_splitbrain/files/models/) and put them in the `models` directory.\n\n**(2)** To extract features, you can (a) use the main branch of Caffe and do color conversion outside of the network or (b) download and install a modified Caffe and not worry about color conversion.\n\n**(a)** **Color conversion outside of prototxt** To extract features with the main branch of [Caffe](http://caffe.berkeleyvision.org/): <br>\n**(i)** Load the downloaded weights with model definition file `deploy_lab.prototxt` in the `models` directory. The input is blob `data_lab`, which is an ***image in Lab colorspace***. You will have to do the Lab color conversion pre-processing outside of the network.\n\n**(b)** **Color conversion in prototxt** You can also extract features with in-prototxt color version with a modified Caffe. <br>\n**(i)** Run `./resources/fetch_caffe.sh`. This will load a modified Caffe into directory `./caffe-colorization`. <br>\n**(ii)** Install the modified Caffe. For guidelines and help with installation of Caffe, consult the [installation guide](http://caffe.berkeleyvision.org/) and [Caffe users group](https://groups.google.com/forum/#!forum/caffe-users). <br>\n**(iii)** Load the downloaded weights with model definition file `deploy.prototxt` in the `models` directory. The input is blob `data`, which is a ***non mean-centered BGR image***.\n\n### Citation ###\nIf you find this model useful for your resesarch, please use this [bibtex](http://richzhang.github.io/index_files/bibtex_cvpr2017_splitbrain.txt) to cite.\n \n"
  },
  {
    "path": "models/deploy.prototxt",
    "content": "\n\nlayer {\n\tname: \"input\"\n\ttype: \"Input\"\n\ttop: \"data\" # BGR image from [0,255] ***NOT MEAN CENTERED***\n\tinput_param { shape { dim: 1 dim: 3 dim: 227 dim: 227 } }\n}\nlayer { # Convert to lab\n  name: \"img_lab\"\n  type: \"ColorConv\"\n  bottom: \"data\"\n  top: \"img_lab\"\n  propagate_down: false\n  color_conv_param {\n    input: 0 # BGR\n    output: 3 # Lab\n  }\n}\nlayer { # 0-center lightness channel\n  name: \"data_lab\"\n  type: \"Convolution\"\n  bottom: \"img_lab\"\n  top: \"data_lab\" # [-50,50]\n  propagate_down: false\n  param {lr_mult: 0 decay_mult: 0}\n  param {lr_mult: 0 decay_mult: 0}\n  convolution_param {\n    kernel_size: 1\n    num_output: 3\n    group: 3\n  }\n}\nlayer {\n  name: \"conv1\"\n  type: \"Convolution\"\n  # bottom: \"img\"\n  bottom: \"data_lab\"\n  # bottom: \"img_bn\"\n  top: \"conv1\"\n  param {lr_mult: 0 decay_mult: 0}\n  param {lr_mult: 0 decay_mult: 0}\n  convolution_param {\n    num_output: 96\n    kernel_size: 11\n    stride: 4\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.01\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 0\n    }\n  }\n}\nlayer {\n  name: \"relu1\"\n  type: \"ReLU\"\n  bottom: \"conv1\"\n  top: \"conv1\"\n}\nlayer {\n  name: \"pool1\"\n  type: \"Pooling\"\n  bottom: \"conv1\"\n  top: \"pool1\"\n  pooling_param {\n    pool: MAX\n    kernel_size: 3\n    stride: 2\n  }\n}\nlayer {\n  name: \"conv2\"\n  type: \"Convolution\"\n  bottom: \"pool1\"\n  top: \"conv2\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 256\n    pad: 2\n    kernel_size: 5\n    group: 2\n  }\n}\nlayer {\n  name: \"relu2\"\n  type: \"ReLU\"\n  bottom: \"conv2\"\n  top: \"conv2\"\n}\nlayer {\n  name: \"pool2\"\n  type: \"Pooling\"\n  # bottom: \"conv2\"\n  bottom: \"conv2\"\n  top: \"pool2\"\n  pooling_param {\n    pool: MAX\n    kernel_size: 3\n    stride: 2\n    # pad: 1\n  }\n}\nlayer {\n  name: \"conv3\"\n  type: \"Convolution\"\n  bottom: \"pool2\"\n  top: \"conv3\"\n  # propagate_down: false\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 384\n    pad: 1\n    kernel_size: 3\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.01\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 0\n    }\n  }\n}\nlayer {\n  name: \"relu3\"\n  type: \"ReLU\"\n  bottom: \"conv3\"\n  top: \"conv3\"\n}\nlayer {\n  name: \"conv4\"\n  type: \"Convolution\"\n  bottom: \"conv3\"\n  top: \"conv4\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 384\n    pad: 1\n    kernel_size: 3\n    group: 2\n  }\n}\nlayer {\n  name: \"relu4\"\n  type: \"ReLU\"\n  bottom: \"conv4\"\n  top: \"conv4\"\n}\nlayer {\n  name: \"conv5\"\n  type: \"Convolution\"\n  bottom: \"conv4\"\n  top: \"conv5\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 256\n    pad: 1\n    kernel_size: 3\n    group: 2\n  }\n}\nlayer {\n  name: \"relu5\"\n  type: \"ReLU\"\n  bottom: \"conv5\"\n  top: \"conv5\"\n}\nlayer {\n  name: \"pool5\"\n  type: \"Pooling\"\n  bottom: \"conv5\"\n  top: \"pool5\"\n  pooling_param {\n    pool: MAX\n    kernel_size: 3\n    stride: 2\n  }\n}\nlayer {\n  name: \"fc6\"\n  type: \"Convolution\"\n  bottom: \"pool5\"\n  top: \"fc6\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    kernel_size: 6\n    dilation: 2\n    pad: 5\n    stride: 1\n    num_output: 4096\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.005\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 1\n    }\n  }\n}\nlayer {\n  name: \"relu6\"\n  type: \"ReLU\"\n  bottom: \"fc6\"\n  top: \"fc6\"\n}\nlayer {\n  name: \"fc7\"\n  type: \"Convolution\"\n  bottom: \"fc6\"\n  top: \"fc7\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    kernel_size: 1\n    stride: 1\n    num_output: 4096\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.005\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 1\n    }\n  }\n}\nlayer {\n  name: \"relu7\"\n  type: \"ReLU\"\n  bottom: \"fc7\"\n  top: \"fc7\"\n}\n"
  },
  {
    "path": "models/deploy_lab.prototxt",
    "content": "\n\nlayer {\n\tname: \"input\"\n\ttype: \"Input\"\n\ttop: \"img_lab\" # image in Lab color space\n\tinput_param { shape { dim: 1 dim: 3 dim: 227 dim: 227 } }\n}\nlayer { # 0-center lightness channel\n  name: \"data_lab\"\n  type: \"Convolution\"\n  bottom: \"img_lab\"\n  top: \"data_lab\" # [-50,50]\n  propagate_down: false\n  param {lr_mult: 0 decay_mult: 0}\n  param {lr_mult: 0 decay_mult: 0}\n  convolution_param {\n    kernel_size: 1\n    num_output: 3\n    group: 3\n  }\n}\nlayer {\n  name: \"conv1\"\n  type: \"Convolution\"\n  # bottom: \"img\"\n  bottom: \"data_lab\"\n  # bottom: \"img_bn\"\n  top: \"conv1\"\n  param {lr_mult: 0 decay_mult: 0}\n  param {lr_mult: 0 decay_mult: 0}\n  convolution_param {\n    num_output: 96\n    kernel_size: 11\n    stride: 4\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.01\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 0\n    }\n  }\n}\nlayer {\n  name: \"relu1\"\n  type: \"ReLU\"\n  bottom: \"conv1\"\n  top: \"conv1\"\n}\nlayer {\n  name: \"pool1\"\n  type: \"Pooling\"\n  bottom: \"conv1\"\n  top: \"pool1\"\n  pooling_param {\n    pool: MAX\n    kernel_size: 3\n    stride: 2\n  }\n}\nlayer {\n  name: \"conv2\"\n  type: \"Convolution\"\n  bottom: \"pool1\"\n  top: \"conv2\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 256\n    pad: 2\n    kernel_size: 5\n    group: 2\n  }\n}\nlayer {\n  name: \"relu2\"\n  type: \"ReLU\"\n  bottom: \"conv2\"\n  top: \"conv2\"\n}\nlayer {\n  name: \"pool2\"\n  type: \"Pooling\"\n  # bottom: \"conv2\"\n  bottom: \"conv2\"\n  top: \"pool2\"\n  pooling_param {\n    pool: MAX\n    kernel_size: 3\n    stride: 2\n    # pad: 1\n  }\n}\nlayer {\n  name: \"conv3\"\n  type: \"Convolution\"\n  bottom: \"pool2\"\n  top: \"conv3\"\n  # propagate_down: false\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 384\n    pad: 1\n    kernel_size: 3\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.01\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 0\n    }\n  }\n}\nlayer {\n  name: \"relu3\"\n  type: \"ReLU\"\n  bottom: \"conv3\"\n  top: \"conv3\"\n}\nlayer {\n  name: \"conv4\"\n  type: \"Convolution\"\n  bottom: \"conv3\"\n  top: \"conv4\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 384\n    pad: 1\n    kernel_size: 3\n    group: 2\n  }\n}\nlayer {\n  name: \"relu4\"\n  type: \"ReLU\"\n  bottom: \"conv4\"\n  top: \"conv4\"\n}\nlayer {\n  name: \"conv5\"\n  type: \"Convolution\"\n  bottom: \"conv4\"\n  top: \"conv5\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    num_output: 256\n    pad: 1\n    kernel_size: 3\n    group: 2\n  }\n}\nlayer {\n  name: \"relu5\"\n  type: \"ReLU\"\n  bottom: \"conv5\"\n  top: \"conv5\"\n}\nlayer {\n  name: \"pool5\"\n  type: \"Pooling\"\n  bottom: \"conv5\"\n  top: \"pool5\"\n  pooling_param {\n    pool: MAX\n    kernel_size: 3\n    stride: 2\n  }\n}\nlayer {\n  name: \"fc6\"\n  type: \"Convolution\"\n  bottom: \"pool5\"\n  top: \"fc6\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    kernel_size: 6\n    dilation: 2\n    pad: 5\n    stride: 1\n    num_output: 4096\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.005\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 1\n    }\n  }\n}\nlayer {\n  name: \"relu6\"\n  type: \"ReLU\"\n  bottom: \"fc6\"\n  top: \"fc6\"\n}\nlayer {\n  name: \"fc7\"\n  type: \"Convolution\"\n  bottom: \"fc6\"\n  top: \"fc7\"\n  param {    lr_mult: 0    decay_mult: 0  }\n  param {    lr_mult: 0    decay_mult: 0  }\n  convolution_param {\n    kernel_size: 1\n    stride: 1\n    num_output: 4096\n    weight_filler {\n      type: \"gaussian\"\n      std: 0.005\n    }\n    bias_filler {\n      type: \"constant\"\n      value: 1\n    }\n  }\n}\nlayer {\n  name: \"relu7\"\n  type: \"ReLU\"\n  bottom: \"fc7\"\n  top: \"fc7\"\n}\n"
  },
  {
    "path": "resources/fetch_caffe.sh",
    "content": "\nwget eecs.berkeley.edu/~rich.zhang/projects/2016_colorization/files/train/caffe-colorization.tar.gz -O ./caffe-colorization.tar.gz\ntar -xvf ./caffe-colorization.tar.gz\n"
  },
  {
    "path": "resources/fetch_models.sh",
    "content": "\nwget eecs.berkeley.edu/~rich.zhang/projects/2017_splitbrain/files/models/model_splitbrainauto_clcl.caffemodel -O ./models/model_splitbrainauto_clcl.caffemodel\nwget eecs.berkeley.edu/~rich.zhang/projects/2017_splitbrain/files/models/model_splitbrainauto_clcl_rs.caffemodel -O ./models/model_splitbrainauto_clcl_rs.caffemodel\n"
  }
]