models icon indicating copy to clipboard operation
models copied to clipboard

In object_detection_tutorial

Open yuanzhuohao opened this issue 9 years ago • 82 comments


ImportError Traceback (most recent call last) in () ----> 1 from utils import label_map_util 2 3 from utils import visualization_utils as vis_util

~/lab/dl/models/object_detection/utils/label_map_util.py in () 20 import tensorflow as tf 21 from google.protobuf import text_format ---> 22 from object_detection.protos import string_int_label_map_pb2 23 24

ImportError: cannot import name 'string_int_label_map_pb2'

yuanzhuohao avatar Jun 17 '17 02:06 yuanzhuohao

you forgot to run this #From tensorflow/models/ protoc object_detection/protos/*.proto --python_out=.

zakizhou avatar Jun 17 '17 03:06 zakizhou

I get an equal error after running

#From tensorflow/models/
protoc object_detection/protos/*.proto --python_out=.
Traceback (most recent call last):
  File "create_pet_tf_record.py", line 40, in <module>
    from object_detection.utils import label_map_util
  File "/home/chris/tensorflow-models/models/object_detection/utils/label_map_util.py", line 22, in <module>
    import string_int_label_map_pb2
ImportError: No module named string_int_label_map_pb2

chbaumgaertner avatar Jun 17 '17 07:06 chbaumgaertner

@chbaumgaertner - Were there an error messages when you ran the protoc command? If it was successful, then you should see a bunch of extra files in the object_detection/protos directory of the form "xxx_pb2.py"

jch1 avatar Jun 17 '17 07:06 jch1

from object_detection.protos import string_int_label_map_pb2

Got this error, shouldn't it be
from protos import string_int_label_map_pb2

Anuraag-Advani avatar Jun 17 '17 08:06 Anuraag-Advani

@jessyuan24 @zakizhou @chbaumgaertner @jch1 @Anuraag-Advani

I found some of reason. but I dont know how to solve it. ipython notebook example file is in "object_detection" folder. So , print(os.getcwd()) will show you "/models/object_detection" but , "from object_detection.utils import label_map_util" this line load utils from "/models" current directory "/models/object_detection" but utils recognize current directory as "/models" So, one trick is work. "from object_detection.utils import label_map_util" --> "from utils import label_map_util" And it works.

But this is just trick. this is not perfact solution. somebody can solve this in windows enviorment please?

june9713 avatar Jun 17 '17 09:06 june9713

Hi guys, I had the same problem. But after running the protoc object_detection/protos/*.proto --python_out=. it worked fine. But my classes name and scores are not printed. Any suggestions? do I need to raise a separate issue?

Vikramank avatar Jun 17 '17 11:06 Vikramank

@Vikramank jessyuan24 is aleady run protoc, but he said error is still showing. And I've had same problem in windows. :-)

june9713 avatar Jun 17 '17 14:06 june9713

@june9713 Maybe I should install protoc first

yuanzhuohao avatar Jun 17 '17 14:06 yuanzhuohao

@jessyuan24 Do you use windows virsion? or linux? If you are using windows, try my suggestion. :-)

june9713 avatar Jun 17 '17 15:06 june9713

@june9713 your trick worked for now, thanks!

chbaumgaertner avatar Jun 17 '17 16:06 chbaumgaertner

@june9713 @jessyuan24 great!

Vikramank avatar Jun 17 '17 16:06 Vikramank

I'm getting this when trying to run protoc

~/models# protoc object_detection/protos/*.proto --python_out=.
object_detection/protos/anchor_generator.proto:11:3: Expected "required", "optional", or "repeated".
object_detection/protos/anchor_generator.proto:11:32: Missing field number.

Any ideas? Using the dl-docker image on a Mac


EDIT: fixed - https://github.com/tensorflow/models/issues/1570

jem-computer avatar Jun 17 '17 20:06 jem-computer

I am not being able to use any model but the 'ssd_mobilenet_v1_coco_11_06_2017' one. I get this error with 'MODEL_NAME = 'faster_rcnn_resnet101_coco_11_06_2017''

DecodeError                               Traceback (most recent call last)
<ipython-input-57-57652895f483> in <module>()
     4     with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
     5         serialized_graph = fid.read()
----> 6         od_graph_def.ParseFromString(serialized_graph)
     7         tf.import_graph_def(od_graph_def, name='')

DecodeError: Error parsing message

Anuraag-Advani avatar Jun 17 '17 21:06 Anuraag-Advani

@june9713 No, I use mac osx

yuanzhuohao avatar Jun 18 '17 01:06 yuanzhuohao

For window users : Use protobuf binary : protoc-3.3.0-win32.zip then : \link\to\protoc object_detection/protos/*.proto --python_out=. > then you can import string_int_label_map_pb2

astrung avatar Jun 18 '17 11:06 astrung

Also, can we using transfer-learning for running locally ? i see that we have a doc about transfer learning on cloud but i can not find any documents that write about transfer learning on local machine . I expected it in pipeline but i can not find it. So how can we config transfer learning on running locally

astrung avatar Jun 18 '17 11:06 astrung

how to run this command? protoc object_detection/protos/*.proto --python_out=.

cmd or python is error

C:\Users\insor\Downloads\protoc-3.3.0-win32\bin>protoc.exe to C:\Users\insor\Desktop\k35 main\object detection\object_detection/protos/*.proto --python_out=. to: No such file or directory

ghost avatar Jun 18 '17 14:06 ghost

@astrung Thanks it works. @insort protoc install at https://github.com/google/protobuf

yuanzhuohao avatar Jun 19 '17 00:06 yuanzhuohao

Also, can any one know about how to config for transfer learning on local machine ?

astrung avatar Jun 19 '17 02:06 astrung

@astrung transfer learning? Could you tell me what does it mean? Actually , I wanna train from scratch , but many error is occured. I followed instruction from "Quick Start: Training a pet detector" and "Running locally" (is mixed)

1 . I downloaded pet image files and annotate files from http://www.robots.ox.ac.uk/~vgg/data/pets/

  1. pet_label_map.pbtxt is already exist in data folder.

  2. make record file(https://github.com/tensorflow/models/blob/master/object_detection/g3doc/running_pets.md) python object_detection/create_pet_tf_record.py
    --label_map_path=object_detection/data/pet_label_map.pbtxt
    --data_dir=pwd
    --output_dir=pwd

  3. most confusing thing is pipeline config file. I dont know how to make config file exactly. /models/object_detection/samples/configs/ directory has some of sample config files. I just choose one file. I choose "faster_rcnn_resnet101_pets.config"

  4. edit faster_rcnn_resnet101_pets.config . some of directory and file path should be changing

  5. Now all ready is done.( I think) Lets start traingin.(https://github.com/tensorflow/models/blob/master/object_detection/g3doc/running_locally.md)

my pipeline_config_path is : '~/Desktop/models/object_detection/models/models/faster_rcnn_resnet101_pets.config' my train_dir is : ~/Desktop/models/object_detection/models/models/train

run below:

python object_detection/train.py --logtostderr
--pipeline_config_path='~/Desktop/models/object_detection/models/models/faster_rcnn_resnet101_pets.config'
--train_dir=~/Desktop/models/object_detection/models/models/train

But failed.

Error Message is as below.

tensorflow.python.framework.errors_impl.NotFoundError: ~/Desktop/models/object_detection/models/models/faster_rcnn_resnet101_pets.config

It means pipeline_config file is not exist. But file is obiously exist!! So I dont know reason. Im finding the reason. If anybody have idea , please help me. Thnaks :-)

june9713 avatar Jun 19 '17 03:06 june9713