Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow - object detection module, error appear when trying to use protoc

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??

like image 576
user1838270 Avatar asked Aug 16 '17 08:08

user1838270


2 Answers

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).

like image 163
Július Marko Avatar answered Nov 14 '22 21:11

Július Marko


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.

  1. Copy the protoc exe file to folder where all the proto files are ie "models-master\models-master\research\object_detection\protos" keep protoc.exe and the *.protoc file in same folder

  2. Next open all the files in folder "models-master\research\object_detection\protos" using notepad++.

  3. 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:-enter image description here

Note:- make sure you open all files and try using the output of step 4 to locate the missing files.

like image 5
mayure098 Avatar answered Nov 14 '22 23:11

mayure098