2

该教程位于http://mxnet.io/tutorials/python/mnist.html上。在这一步:“

from IPython.display import HTML
import cv2
import numpy as np
from mnist_demo import html, script
def classify(img):
    img = img[len('data:image/png;base64,'):].decode('base64')
    img = cv2.imdecode(np.fromstring(img, np.uint8), -1)
    img = cv2.resize(img[:,:,3], (28,28))
    img = img.astype(np.float32).reshape((1,1,28,28))/255.0
    return model.predict(img)[0].argmax()

'''
To see the model in action, run the demo notebook at
https://github.com/dmlc/mxnet-notebooks/blob/master/python/tutorials/mnist.ipynb.
'''
HTML(html + script)

"

ImportError Traceback (last last call last) in () 2 import cv2 3 import numpy as np ----> 4 from mnist_demo import html, script 5 def classifier(img): 6 img = img[len('data:image/ png;base64,'):].decode('base64')

ImportError: No module named mnist_demo

我不知道是什么原因,我在谷歌上找不到答案。有人知道吗?

4

1 回答 1

0

那是因为教程不是写在一个文件中的。您应该将该mnist_demo.py文件与您的教程笔记本放在一起。该文件可以在github 站点上的mxnet-notebooks中找到。:P

于 2016-12-18T13:29:54.923 回答