Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import name 'model_lib_v2' from 'object_detection'

Tags:

tensorflow

I'm trying to train TF2 for object detection. When I run model_main_tf2.py, I get the following error:

Traceback (most recent call last):
  File "C:\Python_venv\trained_models\model_main_tf2.py", line 32, in <module>
    from object_detection import model_lib_v2
ImportError: cannot import name 'model_lib_v2' from 'object_detection' (c:\Python_venv\tensorflow\lib\site-packages\object_detection\__init__.py)

How do I install model_lib_v2?

I tried reinstalling TF and reinstalling TensorFlow-object-detection-API but no luck. I went all over the internet looking for answers.

I found: https://github.com/tensorflow/models/issues/7920 But they don't say how to install model_lib_v2

Unfortunately I cannot use TF1, the goal is to use TF2.

like image 290
Gilson Avatar asked Sep 17 '25 15:09

Gilson


1 Answers

see https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md

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

## Python Package Installation
cd models/research
### Compile protos.

protoc object_detection/protos/*.proto --python_out=.
### Install TensorFlow Object Detection API.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --user --use-feature=2020-resolver .
like image 70
aisriver Avatar answered Sep 19 '25 07:09

aisriver