unknown 3 years ago
parent
commit
842c27eb3a
3 changed files with 14 additions and 7 deletions
  1. 7 5
      compute_features.py
  2. 2 2
      load_features.py
  3. 5 0
      push.bat

+ 7 - 5
compute_features.py

@@ -6,7 +6,8 @@
 '''
 
 import scipy.misc as misc
-import cPickle as pickle
+# import cPickle as pickle
+import _pickle as cPickle
 import tensorflow as tf
 from tqdm import tqdm
 import numpy as np
@@ -24,10 +25,8 @@ slim = tf.contrib.slim
    Recursively obtains all images in the directory specified
 
 '''
-def getPaths(data_dir):
-      
+def getPaths(data_dir):  
    image_paths = []
-
    # add more extensions if need be
    ps = ['jpg', 'jpeg', 'JPG', 'JPEG', 'bmp', 'BMP', 'png', 'PNG']
    for p in ps:
@@ -50,6 +49,8 @@ if __name__ == '__main__':
    model           = a.model
    checkpoint_file = a.checkpoint_file
 
+   print( data_dir, model, checkpoint_file )
+
    # I only have these because I thought some take in size of (299,299), but maybe not
    if 'inception' in model: height, width, channels = 224, 224, 3
    if 'resnet' in model:    height, width, channels = 224, 224, 3
@@ -109,13 +110,14 @@ if __name__ == '__main__':
          logits, end_points = vgg_19(x, is_training=False)
          features = end_points['vgg_19/fc8']
 
+   print('init features...')
    sess  = tf.Session()
    saver = tf.train.Saver()
    saver.restore(sess, checkpoint_file)
 
    feat_dict = {}
    paths = getPaths(data_dir)
-   print 'Computing features...'
+   print('Computing features...')
    for path in tqdm(paths):
       image = misc.imread(path)
       image = misc.imresize(image, (height, width))

+ 2 - 2
load_features.py

@@ -17,11 +17,11 @@ if __name__ == '__main__':
       pkl_file = open(sys.argv[1], 'rb')
       features = pickle.load(pkl_file)
    except:
-      print 'Must provide a pickle file'
+      print('Must provide a pickle file')
       exit()
 
    for image, feature in features.iteritems():
-      print image, ':', feature
+      print(image, ':', feature)
       exit()
 
       # do whatever you want with features

+ 5 - 0
push.bat

@@ -0,0 +1,5 @@
+git pull
+git add -A
+git commit -m 'normal'
+git push origin master
+pause