Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

models/research/object_detection/exporter_main_v2.py give me error "ImportError: cannot import name 'builder'" #11173

Open
AlexandreBourrieau opened this issue Feb 29, 2024 · 1 comment
Assignees
Labels
models:research models that come under research directory type:bug Bug in the code

Comments

@AlexandreBourrieau
Copy link

AlexandreBourrieau commented Feb 29, 2024

On my jetson nano : when using models/research/object_detection/exporter_main_v2.py i got the error "ImportError: cannot import name 'builder'

It was working great 1-2 years ago ... :-( but when I try to git clone the tag v2.6.0, there is no research directory ... it contains only Official and Orbit directory ...

how can i do for git clone the repo from tag 2.6.0 with the research directory inside ??

Can someone help me ?

Thanks !

git clone --recursive https://github.com/tensorflow/models.git

cd models/research
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install .

cd ../..

wget http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8.tar.gz
tar -zxf ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8.tar.gz
rm ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8.tar.gz

set_env PYTHONPATH="/env/python:/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models/research:/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models/research/slim:/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models"

mkdir tfmodel_ssd_mobilenet_v2_320x320_coco17_tpu-8

pip3 install tf_slim

sudo cp -r models/official /usr/local/lib/python3.6/dist-packages

python3 models/research/object_detection/exporter_main_v2.py --input_type float_image_tensor --trained_checkpoint_dir ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8/checkpoint/ --pipeline_config_path ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8/pipeline.config --output_directory tfmodel_ssd_mobilenet_v2_320x320_coco17_tpu-8

I got the error :

Traceback (most recent call last):
  File "models/research/object_detection/exporter_main_v2.py", line 104, in <module>
    from object_detection import exporter_lib_v2
  File "/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models/research/object_detection/exporter_lib_v2.py", line 21, in <module>
    from object_detection.builders import model_builder
  File "/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models/research/object_detection/builders/model_builder.py", line 23, in <module>
    from object_detection.builders import anchor_generator_builder
  File "/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models/research/object_detection/builders/anchor_generator_builder.py", line 26, in <module>
    from object_detection.protos import anchor_generator_pb2
  File "/home/jetson/notebook/Jetbot/6. Détection et suivi d'objet/models/research/object_detection/protos/anchor_generator_pb2.py", line 5, in <module>
    from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder'
@AlexandreBourrieau AlexandreBourrieau added models:research models that come under research directory type:bug Bug in the code labels Feb 29, 2024
@AIprototype
Copy link

@AlexandreBourrieau I had a similar issue with builder.py, I believe I fixed this by following the following steps;

  1. Use protobuf version 3.19.4 for when using object detection
  2. Download builder.py from github repo
  3. Place this downloaded builder.py inside your protobuf installation, I use pyCharm with venv, so for me it is venv/Lib/site-packages/google/protobuf/internal

I did quite a lot of web search to get this solution, hope this works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:research models that come under research directory type:bug Bug in the code
Projects
None yet
Development

No branches or pull requests

3 participants