Search code examples
pythontensorflowversionobject-detection

How to fix errors resulting from version.py on TensorFlow object detection example


I am using anaconda to work with tensorflow and I think I did all the installs for object detection.

You can see the ipynb file here

https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb

and the cell which got the error is the first code cell.

import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile

from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops

if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
  raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!')

When I try to run sample called "object_detection_tutorial.ipynb" I got the following errors. What might be causing errors?

ValueError                                Traceback (most recent call last)
<ipython-input-1-1e9eee4e6961> in <module>
     17 from object_detection.utils import ops as utils_ops
     18 
---> 19 if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
     20   raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!')

~/anaconda3/envs/tensorflow_cpu/lib/python3.7/distutils/version.py in __init__(self, vstring)
     38     def __init__ (self, vstring=None):
     39         if vstring:
---> 40             self.parse(vstring)
     41 
     42     def __repr__ (self):

~/anaconda3/envs/tensorflow_cpu/lib/python3.7/distutils/version.py in parse(self, vstring)
    135         match = self.version_re.match(vstring)
    136         if not match:
--> 137             raise ValueError("invalid version number '%s'" % vstring)
    138 
    139         (major, minor, patch, prerelease, prerelease_num) = \

ValueError: invalid version number '1.13.0-rc1'

Solution

  • It seems your TensorFlow is Pre-release version, and version.py cannot recognize that. So downgrade to TensorFlow 1.12.0 should solve your problem.

    Ref: TensorFlow releases.