Skip to content

Commit

Permalink
Internal changes for slim (tensorflow#3448)
Browse files Browse the repository at this point in the history
* Merged commit includes the following changes:
186565198  by Sergio Guadarrama:

    Applied random_hsv_in_yiq in inception_preprocessing.

--
186501039  by Sergio Guadarrama:

    Applied random_hsv_in_yiq in inception_preprocessing.

--
186013907  by Sergio Guadarrama:

    Internal change

185715309  by Sergio Guadarrama:

    Obviates the need for prepadding on mobilenet v1 and v2 for fully convolutional models.

--
184266252  by Sergio Guadarrama:

    Give build_nasnet_*() functions an optional flag use_aux_head,
    and add an internal-only arg scope to NasNetA*Cell._apply_drop_path().

--
183865228  by Sergio Guadarrama:

    Internal change

179580924  by Sergio Guadarrama:

    Internal change

177320302  by Sergio Guadarrama:

    Internal change

177130184  by Sergio Guadarrama:

    Make slim nets tests faster by using smaller examples of oversized inputs.

--
176965289  by Sergio Guadarrama:

    Internal change

176585260  by Sergio Guadarrama:

    Internal change

176534973  by Sergio Guadarrama:

    Internal change

175526881  by Sergio Guadarrama:

    Internal change

174967704  by Sergio Guadarrama:

    Treat num_classes=0 same as None in a few slim nets overlooked by the recent
    change.

--
174443227  by Sergio Guadarrama:

    Internal change

174281864  by Sergio Guadarrama:

    Internal change

174249903  by Sergio Guadarrama:

    Fix nasnet image classification and object detection by moving the option to turn ON or OFF batch norm training into it's own arg_scope used only by detection

--
173954505  by Sergio Guadarrama:

    Merge pull request tensorflow#2651 from sguada/tmp1

    Fixes imports

    Closes tensorflow#2636

    ORIGINAL_AUTHOR=Jon Shlens <[email protected]>
    COPYBARA_INTEGRATE_REVIEW=tensorflow#2636 from tensorflow:sguada-patch-1 19ff570f52df5ab655c00fb439129b201c5f2dce

--
173928094  by Sergio Guadarrama:

    Remove pending imports

--

PiperOrigin-RevId: 186565198

* Remove internal links.
  • Loading branch information
pkulzc authored and sguada committed Feb 27, 2018
1 parent 599521e commit 629adff
Show file tree
Hide file tree
Showing 28 changed files with 343 additions and 106 deletions.
18 changes: 10 additions & 8 deletions research/slim/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ py_library(
srcs = ["nets/alexnet.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand Down Expand Up @@ -296,7 +296,7 @@ py_library(
srcs = ["nets/inception_utils.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand Down Expand Up @@ -345,7 +345,7 @@ py_library(
srcs = ["nets/inception_resnet_v2.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand Down Expand Up @@ -425,7 +425,7 @@ py_library(
srcs = ["nets/mobilenet_v1.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand Down Expand Up @@ -511,7 +511,7 @@ py_library(
srcs = ["nets/overfeat.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand All @@ -531,7 +531,7 @@ py_library(
srcs = ["nets/pix2pix.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand All @@ -550,7 +550,7 @@ py_library(
srcs = ["nets/resnet_utils.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand Down Expand Up @@ -607,7 +607,7 @@ py_library(
srcs = ["nets/vgg.py"],
srcs_version = "PY2AND3",
deps = [
# "//tensorflow"
# "//tensorflow",
],
)

Expand Down Expand Up @@ -646,6 +646,7 @@ py_test(
py_binary(
name = "train_image_classifier",
srcs = ["train_image_classifier.py"],
paropts = ["--compress"],
deps = [
":dataset_factory",
":model_deploy",
Expand All @@ -669,6 +670,7 @@ py_binary(
py_binary(
name = "export_inference_graph",
srcs = ["export_inference_graph.py"],
paropts = ["--compress"],
deps = [
":dataset_factory",
":nets_factory",
Expand Down
2 changes: 0 additions & 2 deletions research/slim/datasets/build_imagenet_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
import sys
import threading

import google3
import numpy as np
from six.moves import xrange
import tensorflow as tf

tf.app.flags.DEFINE_string('train_directory', '/tmp/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import os
import os.path
import sys
from six.moves import xrange


if __name__ == '__main__':
Expand Down
1 change: 0 additions & 1 deletion research/slim/datasets/process_bounding_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
import os.path
import sys
import xml.etree.ElementTree as ET
from six.moves import xrange


class BoundingBox(object):
Expand Down
2 changes: 1 addition & 1 deletion research/slim/eval_image_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
slim = tf.contrib.slim

tf.app.flags.DEFINE_integer(
'batch_size', 50, 'The number of samples in each batch.')
'batch_size', 100, 'The number of samples in each batch.')

tf.app.flags.DEFINE_integer(
'max_num_batches', None,
Expand Down
2 changes: 1 addition & 1 deletion research/slim/nets/alexnet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def testFullyConvolutional(self):

def testGlobalPool(self):
batch_size = 1
height, width = 300, 400
height, width = 256, 256
num_classes = 1000
with self.test_session():
inputs = tf.random_uniform((batch_size, height, width, 3))
Expand Down
2 changes: 1 addition & 1 deletion research/slim/nets/cyclegan.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import print_function

import numpy as np
from six.moves import xrange

import tensorflow as tf

layers = tf.contrib.layers
Expand Down
1 change: 0 additions & 1 deletion research/slim/nets/dcgan.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from math import log

from six.moves import xrange
import tensorflow as tf
slim = tf.contrib.slim

Expand Down
1 change: 0 additions & 1 deletion research/slim/nets/dcgan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from __future__ import division
from __future__ import print_function

from six.moves import xrange
import tensorflow as tf
from nets import dcgan

Expand Down
14 changes: 7 additions & 7 deletions research/slim/nets/inception_resnet_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def testBuildOnlyUptoFinalEndpoint(self):
if endpoint != 'PreAuxLogits':
self.assertTrue(out_tensor.op.name.startswith(
'InceptionResnetV2/' + endpoint))
self.assertItemsEqual(endpoints[:index+1], end_points)
self.assertItemsEqual(endpoints[:index+1], end_points.keys())

def testBuildAndCheckAllEndPointsUptoPreAuxLogits(self):
batch_size = 5
Expand Down Expand Up @@ -227,8 +227,8 @@ def testHalfSizeImages(self):
[batch_size, 3, 3, 1536])

def testGlobalPool(self):
batch_size = 2
height, width = 400, 600
batch_size = 1
height, width = 330, 400
num_classes = 1000
with self.test_session():
inputs = tf.random_uniform((batch_size, height, width, 3))
Expand All @@ -238,11 +238,11 @@ def testGlobalPool(self):
[batch_size, num_classes])
pre_pool = end_points['Conv2d_7b_1x1']
self.assertListEqual(pre_pool.get_shape().as_list(),
[batch_size, 11, 17, 1536])
[batch_size, 8, 11, 1536])

def testGlobalPoolUnknownImageShape(self):
batch_size = 2
height, width = 400, 600
batch_size = 1
height, width = 330, 400
num_classes = 1000
with self.test_session() as sess:
inputs = tf.placeholder(tf.float32, (batch_size, None, None, 3))
Expand All @@ -257,7 +257,7 @@ def testGlobalPoolUnknownImageShape(self):
logits_out, pre_pool_out = sess.run([logits, pre_pool],
{inputs: images.eval()})
self.assertTupleEqual(logits_out.shape, (batch_size, num_classes))
self.assertTupleEqual(pre_pool_out.shape, (batch_size, 11, 17, 1536))
self.assertTupleEqual(pre_pool_out.shape, (batch_size, 8, 11, 1536))

def testUnknownBatchSize(self):
batch_size = 1
Expand Down
8 changes: 4 additions & 4 deletions research/slim/nets/inception_v1_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def testBuildOnlyUptoFinalEndpoint(self):
inputs, final_endpoint=endpoint)
self.assertTrue(out_tensor.op.name.startswith(
'InceptionV1/' + endpoint))
self.assertItemsEqual(endpoints[:index+1], end_points)
self.assertItemsEqual(endpoints[:index+1], end_points.keys())

def testBuildAndCheckAllEndPointsUptoMixed5c(self):
batch_size = 5
Expand Down Expand Up @@ -159,8 +159,8 @@ def testUnknownImageShape(self):

def testGlobalPoolUnknownImageShape(self):
tf.reset_default_graph()
batch_size = 2
height, width = 300, 400
batch_size = 1
height, width = 250, 300
num_classes = 1000
input_np = np.random.uniform(0, 1, (batch_size, height, width, 3))
with self.test_session() as sess:
Expand All @@ -174,7 +174,7 @@ def testGlobalPoolUnknownImageShape(self):
feed_dict = {inputs: input_np}
tf.global_variables_initializer().run()
pre_pool_out = sess.run(pre_pool, feed_dict=feed_dict)
self.assertListEqual(list(pre_pool_out.shape), [batch_size, 10, 13, 1024])
self.assertListEqual(list(pre_pool_out.shape), [batch_size, 8, 10, 1024])

def testUnknowBatchSize(self):
batch_size = 1
Expand Down
8 changes: 4 additions & 4 deletions research/slim/nets/inception_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def testBuildOnlyUptoFinalEndpoint(self):
inputs, final_endpoint=endpoint)
self.assertTrue(out_tensor.op.name.startswith(
'InceptionV2/' + endpoint))
self.assertItemsEqual(endpoints[:index+1], end_points)
self.assertItemsEqual(endpoints[:index+1], end_points.keys())

def testBuildAndCheckAllEndPointsUptoMixed5c(self):
batch_size = 5
Expand Down Expand Up @@ -273,8 +273,8 @@ def testUnknownImageShape(self):

def testGlobalPoolUnknownImageShape(self):
tf.reset_default_graph()
batch_size = 2
height, width = 300, 400
batch_size = 1
height, width = 250, 300
num_classes = 1000
input_np = np.random.uniform(0, 1, (batch_size, height, width, 3))
with self.test_session() as sess:
Expand All @@ -288,7 +288,7 @@ def testGlobalPoolUnknownImageShape(self):
feed_dict = {inputs: input_np}
tf.global_variables_initializer().run()
pre_pool_out = sess.run(pre_pool, feed_dict=feed_dict)
self.assertListEqual(list(pre_pool_out.shape), [batch_size, 10, 13, 1024])
self.assertListEqual(list(pre_pool_out.shape), [batch_size, 8, 10, 1024])

def testUnknowBatchSize(self):
batch_size = 1
Expand Down
8 changes: 4 additions & 4 deletions research/slim/nets/inception_v3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def testBuildOnlyUptoFinalEndpoint(self):
inputs, final_endpoint=endpoint)
self.assertTrue(out_tensor.op.name.startswith(
'InceptionV3/' + endpoint))
self.assertItemsEqual(endpoints[:index+1], end_points)
self.assertItemsEqual(endpoints[:index+1], end_points.keys())

def testBuildAndCheckAllEndPointsUptoMixed7c(self):
batch_size = 5
Expand Down Expand Up @@ -240,8 +240,8 @@ def testUnknownImageShape(self):

def testGlobalPoolUnknownImageShape(self):
tf.reset_default_graph()
batch_size = 2
height, width = 400, 600
batch_size = 1
height, width = 330, 400
num_classes = 1000
input_np = np.random.uniform(0, 1, (batch_size, height, width, 3))
with self.test_session() as sess:
Expand All @@ -254,7 +254,7 @@ def testGlobalPoolUnknownImageShape(self):
feed_dict = {inputs: input_np}
tf.global_variables_initializer().run()
pre_pool_out = sess.run(pre_pool, feed_dict=feed_dict)
self.assertListEqual(list(pre_pool_out.shape), [batch_size, 11, 17, 2048])
self.assertListEqual(list(pre_pool_out.shape), [batch_size, 8, 11, 2048])

def testUnknowBatchSize(self):
batch_size = 1
Expand Down
14 changes: 7 additions & 7 deletions research/slim/nets/inception_v4_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def testBuildOnlyUpToFinalEndpoint(self):
inputs, final_endpoint=endpoint)
self.assertTrue(out_tensor.op.name.startswith(
'InceptionV4/' + endpoint))
self.assertItemsEqual(all_endpoints[:index+1], end_points)
self.assertItemsEqual(all_endpoints[:index+1], end_points.keys())

def testVariablesSetDevice(self):
batch_size = 5
Expand Down Expand Up @@ -177,8 +177,8 @@ def testHalfSizeImages(self):
[batch_size, 3, 3, 1536])

def testGlobalPool(self):
batch_size = 2
height, width = 400, 600
batch_size = 1
height, width = 350, 400
num_classes = 1000
inputs = tf.random_uniform((batch_size, height, width, 3))
logits, end_points = inception.inception_v4(inputs, num_classes)
Expand All @@ -187,11 +187,11 @@ def testGlobalPool(self):
[batch_size, num_classes])
pre_pool = end_points['Mixed_7d']
self.assertListEqual(pre_pool.get_shape().as_list(),
[batch_size, 11, 17, 1536])
[batch_size, 9, 11, 1536])

def testGlobalPoolUnknownImageShape(self):
batch_size = 2
height, width = 400, 600
batch_size = 1
height, width = 350, 400
num_classes = 1000
with self.test_session() as sess:
inputs = tf.placeholder(tf.float32, (batch_size, None, None, 3))
Expand All @@ -206,7 +206,7 @@ def testGlobalPoolUnknownImageShape(self):
logits_out, pre_pool_out = sess.run([logits, pre_pool],
{inputs: images.eval()})
self.assertTupleEqual(logits_out.shape, (batch_size, num_classes))
self.assertTupleEqual(pre_pool_out.shape, (batch_size, 11, 17, 1536))
self.assertTupleEqual(pre_pool_out.shape, (batch_size, 9, 11, 1536))

def testUnknownBatchSize(self):
batch_size = 1
Expand Down
Loading

0 comments on commit 629adff

Please sign in to comment.