From 425b2dda99a60b135c63d73389208112b3ec09a8 Mon Sep 17 00:00:00 2001 From: hkato Date: Mon, 2 Dec 2019 02:05:59 +0900 Subject: [PATCH] Add training commands --- README.md | 18 +++++++++++ mesh_reconstruction/encoders.py | 3 +- mesh_reconstruction/perceptual_loss.py | 3 +- train_shapenet.sh | 44 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 train_shapenet.sh diff --git a/README.md b/README.md index 2e1e62c..251acfb 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,24 @@ output the following images. ![](https://raw.githubusercontent.com/hiroharu-kato/view_prior_learning/master/data/examples/4231883e92a3c1a21c62d11641ffbd35_00.png) ![](https://raw.githubusercontent.com/hiroharu-kato/view_prior_learning/master/data/examples/4231883e92a3c1a21c62d11641ffbd35_00_shapenet_multi_color_nv20_uvr_cc.gif) +## Training + +Training requires pre-trained AlexNet model. + +```shell script +cd data +mkdir caffemodel +cd caffemodel +wget http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel +cd ../../ +``` + +Training of the provided pre-trained ShapeNet models is done by + +```shell script +bash train_shapenet.sh +``` + ## Citation ``` diff --git a/mesh_reconstruction/encoders.py b/mesh_reconstruction/encoders.py index a4b0b64..5195bcc 100644 --- a/mesh_reconstruction/encoders.py +++ b/mesh_reconstruction/encoders.py @@ -143,7 +143,6 @@ def get_encoder(encoder_name, dim_in, dim_out): if encoder_name == 'resnet18': return ResNet18(dim_in, dim_out) elif encoder_name == 'resnet18pt': - return PreTrainedResNet18(dim_in, dim_out, '/data/unagi0/kato/large_data/caffemodel/resnet-18.caffemodel') - # return PreTrainedResNet18(dim_in, dim_out, '/media/disk2/lab/caffemodel/resnet-18.caffemodel') + return PreTrainedResNet18(dim_in, dim_out, './data/caffemodel/resnet-18.caffemodel') elif encoder_name == 'dummy': return DummyEncoder() diff --git a/mesh_reconstruction/perceptual_loss.py b/mesh_reconstruction/perceptual_loss.py index 9566cfa..6e86fda 100644 --- a/mesh_reconstruction/perceptual_loss.py +++ b/mesh_reconstruction/perceptual_loss.py @@ -13,8 +13,7 @@ def __init__(self): self.conv4 = cl.Convolution2D(None, 384, 3, pad=1) self.conv5 = cl.Convolution2D(None, 256, 3, pad=1) - # caffe_model = chainer.links.caffe.CaffeFunction('/media/disk2/lab/caffemodel/bvlc_alexnet.caffemodel') - caffe_model = chainer.links.caffe.CaffeFunction('/home/mil/kato/large_data/caffemodel/bvlc_alexnet.caffemodel') + caffe_model = chainer.links.caffe.CaffeFunction('./data/caffemodel/bvlc_alexnet.caffemodel') self.conv1.W.data = caffe_model.conv1.W.data.copy() self.conv1.b.data = caffe_model.conv1.b.data.copy() self.conv2.W.data = caffe_model.conv2.W.data.copy() diff --git a/train_shapenet.sh b/train_shapenet.sh new file mode 100644 index 0000000..7745e49 --- /dev/null +++ b/train_shapenet.sh @@ -0,0 +1,44 @@ +#################################################################################################### +# Single-view + +# silhouettes, w/o regularization +python mesh_reconstruction/train.py -eid shapenet_single_sil_nv1 -dd $DD -ni 50000 -ds shapenet -svt 1 -nv 1 -sm 1 + +# silhouettes, w/ regularization +python mesh_reconstruction/train.py -eid shapenet_single_sil_nv1_uvr -dd $DD -ni 100000 -ds shapenet -svt 1 -nv 1 -ld 0.1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_single_sil_nv1_uvr_cc -dd $DD -ni 100000 -ds shapenet -svt 1 -nv 1 -ld 0.2 -cc 1 -sm 1 + +# color, w/o regularization +python mesh_reconstruction/train.py -eid shapenet_single_color_nv1 -dd $DD -ni 50000 -ds shapenet -svt 1 -nv 1 -lp 0.5 -sm 1 + +# color, w/ regularization +python mesh_reconstruction/train.py -eid shapenet_single_color_nv1_uvr -dd $DD -ni 100000 -ds shapenet -svt 1 -nv 1 -lp 0.5 -ld 2 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_single_color_nv1_uvr_cc -dd $DD -ni 100000 -ds shapenet -svt 1 -nv 1 -lp 0.5 -ld 2 -cc 1 -sm 1 + +#################################################################################################### +# Multi-view + +# silhouettes +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv20 -dd $DD -ni 500000 -ds shapenet -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv10 -dd $DD -ni 250000 -ds shapenet -nv 10 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv5 -dd $DD -ni 125000 -ds shapenet -nv 5 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv3 -dd $DD -ni 75000 -ds shapenet -nv 3 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv2 -dd $DD -ni 50000 -ds shapenet -nv 2 -sm 1 + +# silhouettes + regularization +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv20_uvr_cc_long -dd $DD -ni 1000000 -ds shapenet -ld 0.03 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv20_uvr_cc -dd $DD -ni 500000 -ds shapenet -ld 0.03 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv10_uvr_cc -dd $DD -ni 500000 -ds shapenet -nv 10 -ld 0.03 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv5_uvr_cc -dd $DD -ni 250000 -ds shapenet -nv 5 -ld 0.03 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv3_uvr_cc -dd $DD -ni 150000 -ds shapenet -nv 3 -ld 0.03 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_sil_nv2_uvr_cc -dd $DD -ni 100000 -ds shapenet -nv 2 -ld 0.03 -cc 1 -sm 1 + +# color +python mesh_reconstruction/train.py -eid shapenet_multi_color_nv20 -dd $DD -ni 500000 -ds shapenet -lp 0.1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_color_nv2 -dd $DD -ni 50000 -ds shapenet -lp 0.1 -nv 2 -sm 1 + +# color + regularization +python mesh_reconstruction/train.py -eid shapenet_multi_color_nv20_uvr_cc_long -dd $DD -ni 1000000 -ds shapenet -lp 0.1 -nv 20 -ld 0.3 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_color_nv20_uvr_cc -dd $DD -ni 500000 -ds shapenet -lp 0.1 -nv 20 -ld 0.3 -cc 1 -sm 1 +python mesh_reconstruction/train.py -eid shapenet_multi_color_nv2_uvr_cc -dd $DD -ni 100000 -ds shapenet -lp 0.1 -nv 2 -ld 0.3 -cc 1 -sm 1 +