This article is the third day article of Python Advent Calendar 2016. It's a defeated story, so the end ends with an error.
A library that uses DeepLearning to convert images for 3D.
--Create an AWS g2.2xlarge or g2.8xlarge EC2 instance --It is necessary to apply for cancellation of usage restrictions in advance ――Since it uses a lot of storage, the free tier uses all 30GB ――Of course, it's not at all other than AWS.
--CUDA (GPU integrated development environment) --cuDNN (library for running neural network on GPU) --Requires developer registration with NVIDIA --MXNet (DeepLearning library)
--Install pyenv -Building Python 3.x environment with Pyenv (CentOS, Ubuntu) --Install anaconda and openCV -The easiest way to use OpenCV with python --Include images2gif - PinguCarsti / packages / images2gif
――Is it good to refer to this? - deep3d.ipynb --Replace the image in advance --If you do not execute it in the deep3d directory that you have git cloned, you will get a read error of deep3d-symbol.json. --You can copy it to the directory you want to execute. --I didn't use jupyter this time
import mxnet as mx
import numpy as np
import os
import urllib
import cv2
from PIL import Image
from images2gif import writeGif
import logging
logging.basicConfig(level=logging.DEBUG)
if not os.path.exists('deep3d-0050.params'):
urllib.urlretrieve('http://homes.cs.washington.edu/~jxie/download/deep3d-0050.params', 'deep3d-0050.params')
model = mx.model.FeedForward.load('deep3d', 50, mx.gpu(0))
shape = (384, 160)
img = cv2.imread('demo.jpg')
raw_shape = (img.shape[1], img.shape[0])
img = cv2.resize(img, shape)
X = img.astype(np.float32).transpose((2,0,1))
X = X.reshape((1,)+X.shape)
test_iter = mx.io.NDArrayIter({'left': X, 'left0':X})
Y = model.predict(test_iter)
FATAL ERROR!!!!
>>> test_iter = mx.io.NDArrayIter({'left': X, 'left0':X})
>>> Y = model.predict(test_iter)
[16:21:56] src/operator/./reshape-inl.h:311: Using target_shape will be deprecated.
[16:21:57] src/operator/./reshape-inl.h:311: Using target_shape will be deprecated.
[16:21:57] src/operator/./reshape-inl.h:311: Using target_shape will be deprecated.
[16:21:57] /home/ubuntu/mxnet/dmlc-core/include/dmlc/logging.h:235: [16:21:57] src/operator/./cudnn_softmax_activation-inl.h:44: Check failed: (in_data[softmax_activation::kData].ndim()) == (2) Input need to have 2 dimensions when mode=instance.
[16:21:57] /home/ubuntu/mxnet/dmlc-core/include/dmlc/logging.h:235: [16:21:57] src/engine/./threaded_engine.h:306: [16:21:57] src/operator/./cudnn_softmax_activation-inl.h:44: Check failed: (in_data[softmax_activation::kData].ndim()) == (2) Input need to have 2 dimensions when mode=instance.
An fatal error occurred in asynchronous engine operation. If you do not know what caused this error, you can try set environment variable MXNET_ENGINE_TYPE to NaiveEngine and run with debugger (i.e. gdb). This will force all operations to be synchronous and backtrace will give you the series of calls that lead to this error. Remember to set MXNET_ENGINE_TYPE back to empty after debugging.
terminate called after throwing an instance of 'dmlc::Error'
what(): [16:21:57] src/engine/./threaded_engine.h:306: [16:21:57] src/operator/./cudnn_softmax_activation-inl.h:44: Check failed: (in_data[softmax_activation::kData].ndim()) == (2) Input need to have 2 dimensions when mode=instance.
An fatal error occurred in asynchronous engine operation. If you do not know what caused this error, you can try set environment variable MXNET_ENGINE_TYPE to NaiveEngine and run with debugger (i.e. gdb). This will force all operations to be synchronous and backtrace will give you the series of calls that lead to this error. Remember to set MXNET_ENGINE_TYPE back to empty after debugging.
Aborted (core dumped)
why?
Input need to have 2 dimensions when mode=instance.
――Are you handing it over?
test_iter = mx.io.NDArrayIter({'left': X, 'left0':X})
――I read the source code of c ++, but I couldn't solve it ...――It seems that deep3d can also be used for videos, so I want to do my best ――I want to understand the logic of Deep Learning. --AWS is really convenient --python is really convenient ――This time, especially anaconda was godly
Recommended Posts