niektemme / tensorflow-mnist-predict Goto Github PK
View Code? Open in Web Editor NEWUse TensorFlow to predict handwriting
Use TensorFlow to predict handwriting
Hi, thanks you for sharing. I ran the code. It gives me an error
local variable 'nheigth' referenced before assignment
I run it by using:
(tensorflow)xu@xu-ThinkCentre-M72e:~ $ python Predict.py 'HandWrittenDigit2.png'
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
File "Predict.py", line 134, in
main(sys.argv[1])
File "Predict.py", line 129, in main
imvalue = imageprepare(argv)
File "Predict.py", line 100, in imageprepare
if (nheigth == 0): #rare case but minimum is 1 pixel
UnboundLocalError: local variable 'nheigth' referenced before assignment
(tensorflow)xu@xu-ThinkCentre-M72e:~ $ python Predict.py 'HandWrittenDigit2.png'
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
File "Predict.py", line 133, in
main(sys.argv[1])
File "Predict.py", line 128, in main
imvalue = imageprepare(argv)
File "Predict.py", line 99, in imageprepare
if (nheigth == 0): #rare case but minimum is 1 pixel
UnboundLocalError: local variable 'nheigth' referenced before assignment
(tensorflow)xu@xu-ThinkCentre-M72e:~ $
Your work helps me, but i think the variable name "nheigth" is wrong , it should be "nheight". You can find it in line 76/77 of predict_1.py and line 116/117 of predict_2.py.
(working on predict_2.py)
How can I give multiple images at once ?
How can I visualize the final result of this in console ?
How can I print/save the multiple digits in a file (example .txt) ?
this is code:
def predictint(imvalue):
with tf.Graph().as_default():
def addlayer(input_data,insize,outsize,act_function=None):
W=tf.Variable(tf.random_normal([insize,outsize]))
b=tf.Variable(tf.zeros([outsize]))+0.1
out_data=tf.matmul(input_data,W)+b
if act_function==None:
return out_data
elif act_function=="relu":
return tf.nn.relu(out_data)
elif act_function=="softmax":
return tf.nn.softmax(out_data)
else:
return tf.nn.sigmoid(out_data)
x_input=tf.placeholder(tf.float32,[None,784])
#y_input=tf.placeholder(tf.float32,[None,10])
l1=addlayer(x_input,784,64,act_function="relu")
l2=addlayer(l1,64,10,act_function="softmax")
init_op = tf.initialize_all_variables()
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(init_op)
saver.restore(sess, "./model.ckpt")
prediction=tf.argmax(l2,1)
return prediction.eval(feed_dict={x_input: [imvalue]}, session=sess)
Hello there,
I am getting this error :
ValueError : Parent directory of model.ckpt doesn't exist, can't save.
With regards
Hello,
I'm trying your scripts, but i can predict any numbers because when i run create_model1 or create_model2. They finish because they can't save the model.
Here the error code :
Traceback (most recent call last):
File "create_model_1.py", line 61, in <module>
save_path = saver.save(sess, "model1.ckpt"')
File "C:\Users\Laura\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1365, in save
"Parent directory of {} doesn't exist, can't save.".format(save_path))
ValueError: Parent directory of model1.ckpt doesn't exist, can't save.
Thanks.
Jordan
I use spyder for run create_model_2.py and then used the predict_2. but it's get error with restore.
I closed spyder and run predict_2 , this time it is run correct but then i want to run it make error with restore again I closed spyder and open it and it run correct.
what is the problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.