Commit a68fc91f authored by xtx's avatar xtx

1

parent 183d17ae
#import tensorflow as tf
import os
import foolbox
#from foolbox.models import TensorFlowModel, PyTorchModel
import torch
from torch.nn import DataParallel
import torchvision
import numpy as np
from .model import HGD_resnet
#from resnet18.resnet_model import Model
'''
def create_model():
graph = tf.Graph()
with graph.as_default():
images = tf.placeholder(tf.float32, (None, 64, 64, 3))
# preprocessing
_R_MEAN = 123.68
_G_MEAN = 116.78
_B_MEAN = 103.94
_CHANNEL_MEANS = [_R_MEAN, _G_MEAN, _B_MEAN]
features = images - tf.constant(_CHANNEL_MEANS)
model = Model(
resnet_size=18,
bottleneck=False,
num_classes=200,
num_filters=64,
kernel_size=3,
conv_stride=1,
first_pool_size=0,
first_pool_stride=2,
second_pool_size=7,
second_pool_stride=1,
block_sizes=[2, 2, 2, 2],
block_strides=[1, 2, 2, 2],
final_size=512,
version=2,
data_format=None)
logits = model(features, False)
with tf.variable_scope('utilities'):
saver = tf.train.Saver()
return graph, saver, images, logits
'''
def create_fmodel():
'''
graph, saver, images, logits = create_model()
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Session(graph=graph, config=config)
path = os.path.dirname(os.path.abspath(__file__))
path = os.path.join(path, 'resnet18', 'checkpoints', 'model')
saver.restore(sess, tf.train.latest_checkpoint(path))
with sess.as_default():
fmodel = TensorFlowModel(images, logits, bounds=(0, 255))
'''
mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1))
std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1))
......@@ -70,7 +16,3 @@ def create_fmodel():
return fmodel
if __name__ == '__main__':
# executable for debuggin and testing
print(create_fmodel())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment