-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain_neural_network.py
More file actions
executable file
·42 lines (29 loc) · 1.02 KB
/
train_neural_network.py
File metadata and controls
executable file
·42 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import tensorflow as tf
from os import listdir
from os.path import isfile, join
image_path = "/mnt/c/temp/resizedRaspberies/"
#list all filenames in image_path directory
filenames = [f for f in listdir(image_path) if isfile(join(image_path, f))]
#prefix the filenames with image_path
filenames_full_path = [image_path + filename for filename in filenames]
#read images to a tensor
image_queue = tf.train.string_input_producer(filenames_full_path)
reader = tf.WholeFileReader()
key, value = reader.read(image_queue)
X = tf.image.decode_jpeg(value, channels=3)
model = tf.initialize_all_variables()
sess = tf.Session()
sess.run(model)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
images_tensor = sess.run(X)
print(sess.run(key))
coord.request_stop()
coord.join(threads)
sess.close()
#hello = tf.constant('Hello, TensorFlow!')
#sess = tf.Session()
#print(sess.run(hello))
#a = tf.constant(10)
#b = tf.constant(32)
#print(sess.run(a + b))