-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (33 loc) · 1.21 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
from utils import *
import time
from vgg19_model import VGG19
import tensorflow as tf
import numpy as np
from scipy import misc
import pickle
def reconstruct_images():
with open('tmp.pkl', 'rb') as f:
tmp = pickle.load(f)
for key in tmp.keys():
tmp[key] = tmp[key].reshape([1]+list(tmp[key].shape))
targets = []
for layer_name in LAYER_TO_BE_SAVED_LESS:
targets.append(tmp[layer_name])
all_layer = True
if all_layer:
with tf.Graph().as_default():
recon_image_by_given_layer(targets, 'all_layers', 20000, 1000,
use_prior=True, use_all_layers=all_layer)
else:
for key in tmp.keys():
reshaped_target = tmp[key]
with tf.Graph().as_default():
recon_image_by_given_layer(reshaped_target, key, 200000, 10000,
use_summary=False, lr=0.001, use_prior=True)
def main():
data = read_images(print_not_found=True, image_id_file=TEST_IMAGE_ID_FILE,
image_dir=TEST_IMAGE_DIR)
extract_dnn_features(data, save_dir=TEST_IMAGE_FEATURES_FILE_NAME_LESS)
if __name__=="__main__":
main()
print ("Good good study, day day up!")