I'm trying to install Tensorflow and im having trouble compiling the .proto files.
I try running this command in the research folder:
C:/protoc/bin/protoc object_detection/protos/*.proto --python_out=.
but it outputs:
object_detection/protos/*.proto: No such file or directory
Any idea why this is happening?
I have found a solution, it is cumbersome.
It works if i compile them one by one.
e.g.
C:/protoc/bin/protoc object_detection/protos/anchor_generator.proto --python_out=.
Where C:/protoc/bin/protoc is the path to protoc.exe file
This code works for me, try it
protoc-3.4.0-win32\bin\protoc object_detection/protos/*.proto --python_out=.
protoc-3.4.0-win32\bin\protoc is path to protoc.exe file
Related
I've installed tensorflow 2.x for using object detection on windows 10 and follow this tutorial
but this error after run
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
showing.
even run new command
python model_main_tf2.py --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
It is because there is no fpn_b2.py file in the object_detection/protos folder. The protoc command given in the tutorial missed this.
You can run the following from research folder in anaconda prompt
protoc --python_out=. .\object_detection\protos\fpn.proto
1. Check folder in directory ...\object_detection\protos and count how many _pb2.py and .protos (don't count init.py and pychance), if they equal then congratulation this forum not solve that problem, but if not go to no.2
2. Type this on console
protoc --python_out=. .\object_detection\protos\ YYYY .proto
what is YYYY..? is the missing .py in \object_detection\protos... to know it check protos and _pb2.py if 1 of protos don't have match, change the YYYY* with that name ( example : I don't have _pb2.py match at anchor_generator.proto, so I type in console protoc --python_out=. .\object_detection\protos\anchor_generator.proto , and so all)
I try to do the following steps to migrate from TensorFlow 1 to TensorFlow 2: https://www.tensorflow.org/guide/upgrade. I can do this in Google Colab but I can't do this on my laptop.
To do so, I first tried to run the following command in Powershell (I'm on Windows, also my working directory contains the project folder):
tf_upgrade_v2 --intree project/ --outtree project2/ --reportfile report.txt
It says that "The term 'tf_upgrade_v2' is not recognized ..."
Then, I downloaded file tf_upgrade_v2.py from the TensorFlow repository and tries to run the following command:
python tf_upgrade_v2.py --intree project/ --outtree project2/ --reportfile report.txt
It works for some time, then finishes, but there is no changes in the folder.
Finally, I tried this:
tf_upgrade_v2.py --intree project/ --outtree projects2/ --reportfile report.txt
It opens another terminal for some time, then finishes, but there is no changes.
I have TensorFlow 2.0 according to pip list. I use conda
UPD:
conda list doesn't contain tensorflow, only tensorboard, tensorflow-estimator, tensorflow-hub
I had the same issue, running python on windows using Visual Studio 2019. The short version, if you already know the location of the upgrade script, is instead of tf_upgrade_v2.py I needed to run tf_upgrade_v2_main.py as the former simply ran and did nothing.
Detailed steps:
The actual steps to running the upgrade script were more involved to figure out. TLDR; from the folder where you want to perform the upgrade run the following command:
"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python" "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Lib\site-packages\tensorflow\tools\compatibility\tf_upgrade_v2_main.py" --infile NeuralTransfer-tf1.py --outfile NeuralTransfer-tf2.py
Be sure to replace C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\ with the path to your python install directory as needed. Also be sure to set the --infile and --outfile arguments accordingly.
To locate tf_upgrade_v2.py, which per the documentation should be installed with TensorFlow 1.13 and later (including all TF 2.0 builds), simply search for the file in your python install directory in windows explorer.
In my case tf_upgrade_v2.py was located (relative to the install directory) in Lib\site-packages\tensorflow\tools\compatibility\tf_upgrade_v2_main.py as shown in the command line arguments above.
It can be also located under c:\users\user\appdata\roaming\python\python_xx\site-packages (if pip is used pip show tensorflow can be used)
For colab run this:
os.environ.get("tf_upgrade_v2")
And then this:
!tf_upgrade_v2 \
--intree xyz \
--outtree zyx \
--reportfile xyzyx
For me it is working by following line of code.
!tf_upgrade_v2 \
--intree models/xyz/cookbook/ROL/ \
--outtree Rol_v2/ \
--reportfile tree_report.txt
I'm brand new to the Windows environment and have spent several hours trying to install Tensorflow with the object detection tutorial. I've read dozens of threads and seen several videos and have no luck.
Here's where I am at: I have all the Tensorflow dependencies installed and the protoc (version 3.7) executable, but when I run the line object_detection/protos/*.proto --python_out=. I get a no such file or directory error.
Here is what I am running from the command line, from the models directory:
D:\training\Tensorflow\protoc\bin\protoc object_detection/protos/*.proto --python_out=.
I've also tried D:\training\Tensorflow\protoc\bin\protoc research/object_detection/protos/*.proto --python_out=. since the path from my current directory (models) to the proto files is research/object_detection/protos/
This thread suggests compiling each .proto file one by one, and after trying to compile the first with D:\training\Tensorflow\protoc\bin\protoc research/object_detection/protos/anchor_generator.proto --python_out=.
I get this error:
object_detection/protos/grid_anchor_generator.proto: File not found.
object_detection/protos/ssd_anchor_generator.proto: File not found.
object_detection/protos/multiscale_anchor_generator.proto: File not found.
research/object_detection/protos/anchor_generator.proto: Import "object_detection/protos/grid_anchor_generator.proto" was not found or had errors.
research/object_detection/protos/anchor_generator.proto: Import "object_detection/protos/ssd_anchor_generator.proto" was not found or had errors.
research/object_detection/protos/anchor_generator.proto: Import "object_detection/protos/multiscale_anchor_generator.proto" was not found or had errors.
research/object_detection/protos/anchor_generator.proto:13:5: "GridAnchorGenerator" is not defined.
research/object_detection/protos/anchor_generator.proto:14:5: "SsdAnchorGenerator" is not defined.
research/object_detection/protos/anchor_generator.proto:15:5: "MultiscaleAnchorGenerator" is not defined.
Those other .proto files are in fact in the same directory, so I'm not sure why it's not finding them.
What am I doing wrong?
You should run the command from research directory. As specified here.
# From tensorflow/models/research/
D:\training\Tensorflow\protoc\bin\protoc object_detection/protos/*.proto --python_out=.
working on win10 64-bit
when i trying to train my model by E:\projectx\model-master\models-master>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config
this error appear
File "train.py", line 49, in
from object_detection.builders import dataset_builder
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\dataset_builder.py",
line 27, in
from object_detection.data_decoders import tf_example_decoder
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\data_decoders\tf_example_decoder.py",
line 27, in
from object_detection.protos import input_reader_pb2
ImportError: cannot import name 'input_reader_pb2'
i do run protoc 3.4 protoc object_detection/protos/*.proto --python_out=.
but the error still exist
i check all thing and it is should be fine and work, it is going me mad!!
please help....
thanks
As you already compiled all .proto files in object_detection/protos/ . You should see python files which have '_pb2' like eval_pb2. If you can see these then go to models/research directory and run these code one by one:
python setup.py build
python setup.py install
From inside the object_detection folder:
protoc ../object_detection/protos/*.proto --python_out=.
This command will generate a *_pb2.py for each .proto file in the object_detection/protos/ folder.
Note: Is important to specify a path above object_detection, otherwise errors would occur, most likely:
object_detection/protos/ssd_anchor_generator.proto: File not found.
protos/anchor_generator.proto:8:1: Import "object_detection/protos/ssd_anchor_generator.proto" was not found or had errors.
protos/anchor_generator.proto:17:5: "FlexibleGridAnchorGenerator" is not defined.
If the error persists probably you are in the wrong folder, take a look at the output message to see from where it is trying to import the file and execute the command in the right directory.
As last resort: Download the object_detection module from https://github.com/tensorflow/models/tree/master/research
place it in your working directory, enter it and re-execute the command above.
It will surely works as local modules have import priority over sys.path.
If not, the error message would be probably different from the one reported and the problem lies on the tensorflow installation or the protobuf compiler; as here where the problem was caused by the protoc version.
other useful links: https://github.com/tensorflow/models/issues/5264
Maybe you haven't added module slim to PYTHONPATH.It can be done by running below code inside models/research directory.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Seems that you didnt compile protobuf.
For solving it:
Download the latest protoc exe here: https://github.com/google/protobuf/releases (in your case should be win32)
Rename that folder to "protoc"
Put that folder inside models/research
in models/research via console, launch:
protoc/bin/protoc object_detection/protos/*.proto --python_out=.
I dont know exactly if that command will work on windows, but you have to be sure that you are using the protoc compiler that you downloaded (v.3.6) instead of the protoc in your enviroment.
having problems with protoc, the line doesn't work in windows.
I get this errors:
using this line
protoc --proto_path=./object_detection/protos --python_out=c:\testmomo ./object_detection/protos/anchor_generator.proto
I get this error
object_detection/protos/grid_anchor_generator.proto: File not found.
object_detection/protos/ssd_anchor_generator.proto: File not found.
anchor_generator.proto: Import "object_detection/protos/grid_anchor_generator.proto" was not found or had errors.
anchor_generator.proto: Import "object_detection/protos/ssd_anchor_generator.proto" was not found or had errors.
anchor_generator.proto:12:5: "GridAnchorGenerator" is not defined.
anchor_generator.proto:13:5: "SsdAnchorGenerator" is not defined.
what is the problem??
I was trying different things, and figured out where was the problem.
Make sure you're doing it this way:
# From models/
protoc object_detection/protos/*.proto --python_out=.
whereas I was trying to do it like:
# from object_detection/
protoc protos/*.proto --python_out=.
that gives me errors as yours.
Check if you're in the right place (directory).
First make note protoc buffer is quite dumb and does not catches all the files properly, you have two options to manually compile all the 29 files or follow below steps.
Copy the protoc exe file to folder where all the proto files are ie
"models-master\models-master\research\object_detection\protos"
Next open all the files in folder "models-master\research\object_detection\protos" using notepad++.
Press ctrl+f and remove "object_detection/protos/" in all the files
( if you are doing manually also remember the protoc starts in alphabetic order so start from file "anchor_generator.proto").
For example replace:-
import "object_detection/protos/grid_anchor_generator.proto";
import "object_detection/protos/ssd_anchor_generator.proto";
import "object_detection/protos/multiscale_anchor_generator.proto";
with this:-
import "grid_anchor_generator.proto";
import "ssd_anchor_generator.proto";
import "multiscale_anchor_generator.proto";
4.Now open Cmd in the same directory ie
"\models master\research\object_detection\protos"
type:-
protoc *.proto --python_out=.
notice you will get new .py file in the folder and no errors on execution of above file.
5.output:-
Note:- make sure you open all files and try using the output of step 4 to locate the missing files.
seems like there is no file: object_detection/protos/grid_anchor_generator.proto and ssd_ancho_generator.proto
did you just clone the models repostitory or have modified something?
In object_detection protos folder the import line is given
import "object_detection/protos/grid_anchor_generator.proto";
Change that to
import "research/object_detection/protos/grid_anchor_generator.proto";
Simply, run protocbuf for each one of them.
protoc object_detection/protos/grid_anchor_generator.proto
--python_out=.