Models: object_detection_tutorial comparison tf.__version__ < '1.4.0' for version 1.10.0

Created on 12 Aug 2018  路  3Comments  路  Source: tensorflow/models

Minor stuff,
Context:
models/research/object_detection/object_detection_tutorial

if tf.__version__ < '1.4.0':
  raise ImportError('Please upgrade your tensorflow installation to v1.4.* or later!')

Issue:
However,
if tf.__version__ is '1.10.0'
'1.10.0' < '1.4.0'=> True, which will raise ImportError even if 1.10.0 is higher.

Most helpful comment

Delete the if case. Thats how i fixed mine :)

All 3 comments

Delete the if case. Thats how i fixed mine :)

the check is performed on strings, instead of ints... which is causing a failure with comparing the '4' and '10'.

I'm sure there is a more elegant solution... but you could use:

MIN_TF_VERSION_MAJOR = 1
MIN_TF_VERSION_MINOR = 9
tf_ver = [int(s) for s in tf.__version__.split('.')]

if tf_ver[0] < MIN_TF_VERSION_MAJOR or (tf_ver[0] == MIN_TF_VERSION_MAJOR and tf_ver[1] < MIN_TF_VERSION_MINOR):
  raise ImportError('Please upgrade your tensorflow installation to v{0}.{1}.* or later!'.format(MIN_TF_VERSION_MAJOR, MIN_TF_VERSION_MINOR))

Closing as this is resolved

Was this page helpful?
0 / 5 - 0 ratings