-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
66 lines (44 loc) · 1.32 KB
/
main.py
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
43
44
45
46
47
48
49
50
51
52
53
54
from PIL import Image
import os, sys
import tensorflow as tf
import numpy as np
import csv
#constants
_imgPath = 'bc_photos/mdb'
#image = Image.open('bc_photos/mdb322.pgm')
#image.save('bc_photos/mdb322.jpg')
#image.delete('bc_photos/mdb010.jpg')
#os.remove('bc_photos/mdb005.jpg')
def convert_to_jpg(path):
for i in range(321):
if i < 9:
img_path = _imgPath+'00'+str(i+1)
elif i<99:
img_path = _imgPath+'0'+str(i+1)
else:
img_path = _imgPath+str(i+1)
img = Image.open(img_path+'.pgm')
img.save(img_path+".jpg")
#os.remove(img_path+'.pgm')
#only convert once.
#convert_to_jpg(_imgPath)
#get list of filenames for tensorflow input
def get_file_names(path):
filenames = []
for i in range(322):
if i < 9:
temp_path = path+'00'+str(i+1)
elif i<99:
temp_path = path+'0'+str(i+1)
else:
temp_path = path+str(i+1)
filenames.append(temp_path+'.jpg')
#print(filenames)
return filenames
# returns queue for holding filenames using tf
def get_queue():
#get filenames
fns = get_file_names(_imgPath)
lbls = gen_labels('photo_labels.txt')
#return tf.train.string_input_producer(fns)
return tf.train.slice_input_producer([fns,lbls], num_epochs=10, shuffle=True)