Commit 088ec5d2 authored by cclauss's avatar cclauss
Browse files

long was removed in Python 3 (en masse)

parent 96e2c0ee
...@@ -12,6 +12,7 @@ import random ...@@ -12,6 +12,7 @@ import random
from absl import logging from absl import logging
import numpy as np import numpy as np
import six
from six.moves import xrange from six.moves import xrange
import tensorflow as tf import tensorflow as tf
...@@ -138,7 +139,7 @@ def stack_pad(tensors, pad_axes=None, pad_to_lengths=None, dtype=np.float32, ...@@ -138,7 +139,7 @@ def stack_pad(tensors, pad_axes=None, pad_to_lengths=None, dtype=np.float32,
same_axes = dict(enumerate(max_lengths)) same_axes = dict(enumerate(max_lengths))
if pad_axes is None: if pad_axes is None:
pad_axes = [] pad_axes = []
if isinstance(pad_axes, (int, long)): if isinstance(pad_axes, six.integer_types):
if pad_to_lengths is not None: if pad_to_lengths is not None:
max_lengths[pad_axes] = pad_to_lengths max_lengths[pad_axes] = pad_to_lengths
del same_axes[pad_axes] del same_axes[pad_axes]
......
...@@ -21,6 +21,7 @@ from __future__ import unicode_literals ...@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import math import math
import numpy as np import numpy as np
import six
import tensorflow as tf import tensorflow as tf
...@@ -39,7 +40,7 @@ class RsqrtInitializer(object): ...@@ -39,7 +40,7 @@ class RsqrtInitializer(object):
1.0 / sqrt(product(shape[dims])) 1.0 / sqrt(product(shape[dims]))
**kwargs: Extra keyword arguments to pass to tf.truncated_normal. **kwargs: Extra keyword arguments to pass to tf.truncated_normal.
""" """
if isinstance(dims, (int, long)): if isinstance(dims, six.integer_types):
self._dims = [dims] self._dims = [dims]
else: else:
self._dims = dims self._dims = dims
...@@ -73,7 +74,7 @@ class RectifierInitializer(object): ...@@ -73,7 +74,7 @@ class RectifierInitializer(object):
sqrt(scale / product(shape[dims])). sqrt(scale / product(shape[dims])).
**kwargs: Extra keyword arguments to pass to tf.truncated_normal. **kwargs: Extra keyword arguments to pass to tf.truncated_normal.
""" """
if isinstance(dims, (int, long)): if isinstance(dims, six.integer_types):
self._dims = [dims] self._dims = [dims]
else: else:
self._dims = dims self._dims = dims
......
...@@ -42,6 +42,11 @@ import tensorflow as tf ...@@ -42,6 +42,11 @@ import tensorflow as tf
from object_detection.dataset_tools import oid_tfrecord_creation from object_detection.dataset_tools import oid_tfrecord_creation
from object_detection.utils import label_map_util from object_detection.utils import label_map_util
try:
long # Python 2
except NameError:
long = int # Python 3
tf.flags.DEFINE_string('input_annotations_csv', None, tf.flags.DEFINE_string('input_annotations_csv', None,
'Path to CSV containing image bounding box annotations') 'Path to CSV containing image bounding box annotations')
tf.flags.DEFINE_string('input_images_directory', None, tf.flags.DEFINE_string('input_images_directory', None,
......
...@@ -203,9 +203,9 @@ def padded_one_hot_encoding(indices, depth, left_pad): ...@@ -203,9 +203,9 @@ def padded_one_hot_encoding(indices, depth, left_pad):
TODO: add runtime checks for depth and indices. TODO: add runtime checks for depth and indices.
""" """
if depth < 0 or not isinstance(depth, (int, long) if six.PY2 else int): if depth < 0 or not isinstance(depth, six.integer_types):
raise ValueError('`depth` must be a non-negative integer.') raise ValueError('`depth` must be a non-negative integer.')
if left_pad < 0 or not isinstance(left_pad, (int, long) if six.PY2 else int): if left_pad < 0 or not isinstance(left_pad, six.integer_types):
raise ValueError('`left_pad` must be a non-negative integer.') raise ValueError('`left_pad` must be a non-negative integer.')
if depth == 0: if depth == 0:
return None return None
......
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