前提
初歩的な質問でしたら申し訳ございません。
三次元再構築の分野に興味を持っていて、https://github.com/hiroharu-kato/mesh_reconstructionのコードを実験してみたところ、エラーが発生しました。
引数が間違っているというエラーなのはわかるのですが、python2やchainerに疎いため、どこをどう直せばいいのかよくわかりません。
試したこと
Readmeに従い、neural rendererをセットアップし、学習済みモデルをダウンロードした後、mesh_reconstruction/reconstruct.pyを実行。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "mesh_reconstruction/reconstruct.py", line 81, in <module> run() File "mesh_reconstruction/reconstruct.py", line 61, in run model.to_gpu() File "/home/ubuntu/mesh_reconstruction/mesh_reconstruction/models.py", line 114, in to_gpu super(Model, self).to_gpu() File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/device_resident.py", line 104, in to_gpu self.__to_device(visitor) File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/device_resident.py", line 149, in __to_device self.device_resident_accept(to_device_visitor) File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/link.py", line 959, in device_resident_accept d[name].device_resident_accept(visitor) File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/link.py", line 956, in device_resident_accept super(Chain, self).device_resident_accept(visitor) File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/link.py", line 447, in device_resident_accept super(Link, self).device_resident_accept(visitor) File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/device_resident.py", line 38, in device_resident_accept visitor.visit_device_resident(self) File "/home/ubuntu/anaconda3/envs/neural_renderer/lib/python2.7/site-packages/chainer/device_resident.py", line 269, in visit_device_resident to_method(**kwargs) TypeError: to_gpu() got an unexpected keyword argument 'device'
該当のソースコード
##reconstruct.py
python2
1def run(): 2 (省略) 3 4 # setup model & optimizer 5 model = models.Model() 6 model.to_gpu() 7 chainer.serializers.load_npz(os.path.join(directory_output, 'model.npz'), model) 8 9 (省略) 10 11if __name__ == '__main__': 12 run()
##models.py
python2
1class Model(chainer.Chain): 2 def __init__(self, filename_obj='./data/obj/sphere_642.obj', lambda_smoothness=0.): 3 super(Model, self).__init__() 4 self.lambda_smoothness = lambda_smoothness 5 self.vertices_predicted_a = None 6 self.vertices_predicted_b = None 7 with self.init_scope(): 8 self.encoder = Encoder() 9 self.decoder = Decoder(filename_obj) 10 self.smoothness_loss_parameters = loss_functions.smoothness_loss_parameters(self.decoder.faces) 11 12 self.renderer = renderer.Renderer() 13 self.renderer.image_size = 64 14 self.renderer.viewing_angle = 15. 15 self.renderer.anti_aliasing = True 16 17 def to_gpu(self, device=None): 18 super(Model, self).to_gpu() 19 self.smoothness_loss_parameters = [chainer.cuda.to_gpu(p) for p in self.smoothness_loss_parameters] 20 21 (省略)
補足情報(FW/ツールのバージョンなど)
ubuntu 18.04
Chainer 6.3.0
Cupy 6.7.0
あなたの回答
tips
プレビュー