File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This script works only for PNG Files
2
+ # If you need JPG/JPEG images, the decode
3
+ # function has to be changed
4
+ #
5
+
6
+ import tensorflow as tf
7
+ import sys
8
+ import PIL
9
+ from PIL import Image
10
+ import numpy as np
11
+
12
+ image_path = sys .argv [1 ]
13
+ filename_queue = tf .train .string_input_producer ([image_path ])
14
+ reader = tf .WholeFileReader ()
15
+ key , value = reader .read (filename_queue )
16
+ my_img = tf .image .decode_png (value )
17
+ init_op = tf .initialize_all_variables ()
18
+
19
+ with tf .Session () as sess :
20
+ sess .run (init_op )
21
+ coord = tf .train .Coordinator ()
22
+ threads = tf .train .start_queue_runners (coord = coord )
23
+
24
+ for i in range (1 ):
25
+ image = my_img .eval ()
26
+
27
+ print (image .shape )
28
+ print (PIL .Image .fromarray (np .asarray (image )))
29
+
30
+ coord .request_stop ()
31
+ coord .join (threads )
32
+
You can’t perform that action at this time.
0 commit comments