13 sys.path.append(os.path.dirname(os.path.realpath(__file__)))
20 import tensorflow
as tf
21 import netvlad_tf.net_from_mat
as nfm
22 import netvlad_tf.nets
as nets
31 print(
"NetVLAD python init()")
40 tf.compat.v1.disable_eager_execution()
41 tf.compat.v1.reset_default_graph()
43 image_batch = tf.compat.v1.placeholder(
44 dtype=tf.float32, shape=[
None,
None,
None, 3])
46 net_out = nets.vgg16NetvladPca(image_batch)
47 saver = tf.compat.v1.train.Saver()
49 sess = tf.compat.v1.Session()
50 saver.restore(sess, nets.defaultCheckpoint())
54 print(f
"NetVLAD python extract{image.shape}")
60 if(image.shape[2] == 1):
61 image = np.dstack((image, image, image))
63 batch = np.expand_dims(image, axis=0)
64 result = sess.run(net_out, feed_dict={image_batch: batch})
69 if(result.shape[1] > dim):
71 result = v/np.linalg.norm(v)
73 return np.float32(result)
76 if __name__ ==
'__main__':
78 img = np.zeros([100,100,3],dtype=np.uint8)
82 print(descriptor.shape)