0

Background

I've been trying to follow the tutorial in this video. The goal is trying to install TensorFlow and TensorFlow's object_detection module.

Goal

How do I install it so that I can follow the rest of the tutorial? I only want to install the CPU version.

Additional Information

Errors that I ran into

  1. ERROR: Could not find a version that satisfies the requirement tensorflow==2.1.0 (from versions: None) ERROR: No matching distribution found for tensorflow
  2. ERROR: tensorflow.whl is not a supported wheel on this platform.

##Research##

  1. https://github.com/tensorflow/tensorflow/issues/39130
  2. Tensorflow installation error: not a supported wheel on this platform
Shella
  • 89
  • 1
  • 7

1 Answers1

1

Prologue

I found this ridiculously complex, if anyone else has a simpler way to install this package please let everyone else know.

Main resource is https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#set-env

Summary of Steps

  1. Newest update of python (x64 bit) which you can install here -
  2. Create a virtual environment from that newest version of python
  3. Get the latest version of TensorFlow from Google - https://www.tensorflow.org/install/pip#package-location
  4. Install latest version of TensorFlow using pip with --upgrade tag and link from above step
  5. Get latest version of protoc (data transfer protocol) - https://github.com/protocolbuffers/protobuf/releases
  6. Install protoc and add location to path so you can easily call it later
  7. Get TensorFlow Garden files from here - https://github.com/tensorflow/models
  8. Copy to a location and add a folder structure models
  9. Compile Protobufs for each model from the TensorFlow Garden using protoc
  10. Set up COCO API to connect to the COCO dataset
  11. Copy the setup file from TensorFlow2 in the TensorFlow Garden object_detection module
  12. Run the installation for object_detection module & hope for the best

Detailed Descriptions

  1. I ran into a problem when first attempting to install object_detection because my version of python wasn't supported
    Get the latest version by going to this page - https://www.python.org/downloads/
    Click "Download Python 3.9.X"
    Once downloaded, run the installation file
  2. Navigate to where python was installed and copy the path to the executable.
    Open up command prompt by going Windows Key -> cmd
    Navigate to where you would like to create the virtual environment by using the cd "path/to/change/directory/to"
    then type "previously/copied/python/executable/path/python.exe" -m venv "name_of_your_virtual_environment"
  3. TensorFlow seems to be supported by google storage api and not by pip to find the link to the latest stable TensorFlow use
    this website https://www.tensorflow.org/install/pip#package-location
    Now grab the TensorFlow installation link that matches your version of python.
    Since mine was version 3.9 and windows I got this link - https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.6.0-cp39-cp39-win_amd64.whl
  4. Install TensorFlow by getting the python.exe from your virtual environment "name_of_your_virtual_environment"
    "name_of_your_virtual_environment/Scripts/python.exe" -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.6.0-cp39-cp39-win_amd64.whl
    Note that you have to use the upgrade tag for some reason
  5. Because TensorFlow is a Google thing they use a special data interchange format called Protobuffs
    Find the latest version of this tool by navigating to their website - https://github.com/protocolbuffers/protobuf/releases
    Find the link under newest releases that matches your operating system aka windows and architecture x64
    I chose https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protoc-3.17.3-win64.zip
  6. To install this thing extract the .zip file and put into "C://Program Files/Google Protoc"
    Get the folder location that has the protoc executable and add it to your environment variables
    To edit your environmental variables press the Windows Key and search for "Environmental Variables" click on "Edit the system Environment Variables"
    Then click "Environmental Variables"
    Navigate to the "Path" environment variable under your user, select it and click edit
    Click new and paste the executable location of protoc, aka "C:/Program Files/GoogleProtoc/bin"
  7. Now to get the actual code for the object_detection module which is supoorted by researchers and is separate to base TensorFlow
    Navigate to TensorFlow Garden - https://github.com/tensorflow/models
    Download or clone the repository
  8. Copy the files to another location using the following structure
    • TensorFlow
      • -> models (You have to add this folder)-> community
        • -> official
        • -> orbit
        • -> research
  9. Restart your command prompt. It will need to be restarted to take into account changes in environmental variables. In this case
    Path because you added protoc on there to make it easier to call from your command prompt
    Again that is Windows Key -> Search cmd
    Navigate inside the research folder with cd "TensorFlow/models/research/"
    Run the command to download and compile Protobuf libraries for /f %i in ('dir /b object_detection\protos\*.proto') do protoc object_detection\protos\%i --python_out=.
  10. Install COCO API so that you can access the dataset. It is a requirement of TensorFlow's object_detection api
    Ensure you are still in the folder "TensorFlow/models/research/"
    Copy the setup python file to the folder you're in using copy object_detection/packages/tf2/setup.py .
    Now use pip to perform the installation "name_of_your_virtual_environment/Scripts/python.exe" -m pip install --use-feature=2020-resolver
  11. Move the set up python file for TensorFlow 2 into the directory which will install the object_detection module.
    Go into "TensorFlow/models/research/object_detection/packages/tf2/setup.py" and move that to "TensorFlow/models/research/object_detection/setup.py"
  12. Now run the installation process for the object_detection module
    Open CMD and navigate to "TensorFlow/models/research/object_detection/" by using cd command
    Using your virtual environment run the script "name_of_your_virtual_environment/Scripts/python.exe" setup.py

Error Guides

ERROR: Could not find a version that satisfies the requirement tensorflow==2.1.0 (from versions: None) ERROR: No matching distribution found for tensorflow

This occurs because your version of Python isn't correct or the architecture is wrong 32bit instead of 64bit. Fix this by downloading a new version of Python and creating a new virtual environment.

ERROR: tensorflow.whl is not a supported wheel on this platform.

Similar to above your version of Python might be wrong or you have selected the wrong link from the TensorFlow repo from Google Storage API. Start at the beginning, download the newest version of Python, create your new virtual environment and then download the right version of TensorFlow that matches the Python version, your operating system (e.g. MAC, Linux or Windows).

Shella
  • 89
  • 1
  • 7