Tensorflow Object Detection API on Windows - error "ModuleNotFoundError: No module named 'utils'"
tensorflow object detection api tutorial
retinanet tensorflow object detection api
object recognition api
mask rcnn tensorflow object detection api
tensorflow 2.0 object detection
object detection using tensorflow github
faster rcnn tensorflow object detection
I'm attempting to get the TensorFlow Object Detection API
working on Windows by following the install instructions
Which seem to be for Linux/Mac. I can only get this to work if I put a script in the directory I cloned the above repo to. If I put the script in any other directory I get this error:
ModuleNotFoundError: No module named 'utils'
I suspect that the cause is not properly doing the Windows equivalent of this command listed on the install instructions above:
# From tensorflow/models/research/ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
I'm using Windows 10, Python 3.6, and TensorFlow 1.4.0 if that matters. Of course, I've Googled on this concern and found various links, for example, this:
But this has not resolved the concern. Any suggestions on how to resolve this?
Here are the steps I've done so far specifically:
EDIT: these steps work now after updating to incorporate RecencyEffect's answer
1) Install TensorFlow and related tools via pip3
2) From an administrative command prompt, run the following:
pip3 install pillow pip3 install lxml pip3 install jupyter pip3 install matplotlib
3) Clone the TensorFlow "models" repository to the Documents folder, in my case
4) Downloaded Google Protobuf https://github.com/google/protobuf Windows v3.4.0 release "protoc-3.4.0-win32.zip" (I tried the most current 3.5.1 and got errors on the subsequent steps, so I tried 3.4.0 per this vid https://www.youtube.com/watch?v=COlbP62-B-U&list=PLQVvvaa0QuDcNK5GeCQnxYnSSaar2tpku&index=1 and the protobuf compile worked)
5) Extract the Protobuf download to Program Files, specifically
6) CD into the models\research directory, specifically
7) Executed the protobuf compile, specifically
"C:\Program Files\protoc-3.4.0-win32\bin\protoc.exe" object_detection/protos/*.proto --python_out=.
and verify the .py files were created successfully as a result of the compile (only the .proto files were there to begin with)
8) cd to the object_detection directory, ex:
then enter the following at a command prompt to start the object_detection_tutorial.ipynb Jupyter Notebook
9) In the Jupyter Notebook, choose "object_detection_tutorial.ipynb" -> Cell -> Run all, the example should run within the notebook
10) In the Jupyter Notebook, choose "File" -> "Download As" -> "Python", and save the .py version of the notebook to the same directory, i.e.
You can now open the script in your chosen Python editor (ex. PyCharm) and run it.
EDIT per RecencyEffect's answer below, if you follow these additional steps you will be able to run the object_detection_tutorial.py script from any directory
11) Move the script to any other directory, then attempt to run it and you will find you will get the error:
ModuleNotFoundError: No module named 'utils'
because we have not yet informed Python how to find the utils directory that these lines use:
from utils import label_map_util from utils import visualization_utils as vis_util
To resolve this . . .
12) Go to System -> Advanced system settings -> Environment Variables . . . -> New, and add a variable with the name PYTHONPATH and these values:
13) Also under Environment Variables, edit PATH and add %PYTHONPATH% like so:
14) Reboot to make sure these path changes take effect
15) Pull up a command prompt and run the command "set", verify PYTHONPATH is there and PYTHONPATH and PATH contained the values from the previous steps.
16) Now you can copy the "object_detection_tutorial.py" to any other directory and it will run
As mentioned in the comment,
utils is a submodule so you actually need to add
I'm glad it worked for you.
Tensorflow Object Detection API on Windows - error , Tensorflow Object Detection API on Windows - error “ModuleNotFoundError: No module named 'utils'” #3164. Closed. Sorry for posting a dumb question, as somebody on Stack Overflow just pointed out, all I had to do was to add. C:\Users\cdahms\Documents\models\research\object_detection
- export PATH=~/anaconda3/bin:$PATH
- git clone https://github.com/tensorflow/models.git
4.protoc object_detection/protos/string_int_label_map.proto --python_out=.
- protoc protos/string_int_label_map.proto --python_out=.
EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial , As mentioned in the comment, utils is a submodule so you actually need to add object_detection to PYTHONPATH , not object_detection/utils . Yes, you can run the Tensorflow Object Detection API on Windows. Unfortunately it is a bit tricky and the official documentation does not reflect that appropriately. I used the following procedure: Install Tensorflow natively on Windows with Anaconda + CUDA + cuDNN. Note that TF 1.5 is now built against CUDA 9.0, so make sure you download the appropriate versions.
The following command does not work on Windows:
Instead, I followed the directions of this tutorial, which recommends setting the path variables for three different directories manually. I simply added a path for the utils directory as well. So far it has worked without error.
Tensorflow Object Detection API on Windows - error, Around July 2017, TensorFlow's Object Detection API was released. This error is because we are yet to inform Python how to find the utils The TensorFlow Object Detection API is an open source framework built on top of TensorFlow that makes it easy to construct, train and deploy object detection models. What makes this API huge is that unlike other models like YOLO, SSD, you do not need a complex hardware setup to run it.
Make sure you have a
__init__.py file in your research/object_detection/protos folder! The
__init__.py file is empty but needs to exist for the protos module to be created correctly.
How to use TensorFlow Object Detection API On Windows, In this article, we will install the Tensorflow Object Detection API and test it out using To install the cocoapi on windows the following command can be used: the Tensorflow Object Detection API can be hard because there are lots of errors How to use TensorFlow Object Detection API On Windows Problem you will probably face : Source of this error are these two lines in the code. Issue Resolution : In system variables, edit PATH and add %PYTHON_PATH%. Some output samples. For experimenting with this API, I used my webcam and mobile’s
Installing the Tensorflow Object Detection API, If the above code shows an error, then check to make sure you have activated the Download cuDNN v7.6.5 Library for Windows 10; Extract the contents of the zip The Tensorflow Object Detection API uses Protobufs to configure model and Tensorflow Object Detection API on Windows - ImportError: No module named “object_detection.utils”; “object_detection” is not a package 0 No module named 'object_detection'
Installation, Installing Tensorflow's Object Detection API is not as straight forward we would like. In this article we will go over how to install it in Windows. for this to work. Otherwise, you will be prompted with an error message to upgrade TensorFlow. The TensorFlow Object Detection API uses.proto files which need to be compiled into.py files. Google provides a program called Protobuf that will batch compile these for you. Note: Download version
Tensorflow Object Detection API Windows Install Guide, This is because Tensorflow Object Detection API use .proto files and these And if no errors then you can assume everything is working properly. I would recommend you to switch to a Linux or Windows environment but PLEASE upgrade to Tensorflow 2.x, "tensorflow upgrade guide" is not completely useful. #454 opened Mar 6, 2020 by 12343954 AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'
- Did you try adding
object_detection/utils? Also, is the import in your code or in the object_detection code?
- ?? OMG where was I on that one ?? Yes, I just added "C:\Users\cdahms\Documents\models\research\object_detection\utils" to PYTHONPATH as well and now it works. If you post the same comment as an answer I'll accept it so you get credit, thanks.
- Thanks for the solution... it has been bothering me for hours.