Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
624 views
in Technique[技术] by (71.8m points)

tensorflow - ImportError: cannot import name 'abs'

I got problem while doing object detection using tensorflow-gpu

I was follwing the youtube tutorials :https://www.youtube.com/watch?v=Rgpfk6eYxJA

I'm trying to detect object using tensorflow-gpu with virtual environment.

I added python, cuda, tensorflow to system environment variables, and also did make training models with labels.

I converted xml labels to csv using xml_to_csv.py.

The problem is when I try to generate tfrecord using generate_tfrecord.py, that error appear. Please help

Here's the code

(tensorflow) C:Usersice305ensorflowmodels
esearchobject_detection>python generate_tfrecord.py --csv_input=imagesrain_labels.csv --image_dir=imagesrain --output_path=train.record
Traceback (most recent call last):
  File "generate_tfrecord.py", line 17, in <module>
    import tensorflow as tf
  File "C:Anaconda3envsensorflowlibsite-packagesensorflow\__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpython\__init__.py", line 81, in <module>
    from tensorflow.python import keras
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkeras\__init__.py", line 24, in <module>
    from tensorflow.python.keras import activations
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkerasactivations\__init__.py", line 22, in <module>
    from tensorflow.python.keras._impl.keras.activations import elu
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkeras\_implkeras\__init__.py", line 21, in <module>
    from tensorflow.python.keras._impl.keras import activations
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkeras\_implkerasactivations.py", line 23, in <module>
from tensorflow.python.keras._impl.keras import backend as K
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkeras\_implkerasackend.py", line 38, in <module>
    from tensorflow.python.layers import base as tf_base_layers
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonlayersase.py", line 25, in <module>
    from tensorflow.python.keras.engine import base_layer
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkerasengine\__init__.py", line 21, in <module>
    from tensorflow.python.keras.engine.base_layer import InputSpec
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkerasenginease_layer.py", line 33, in <module>
    from tensorflow.python.keras import backend
  File "C:Anaconda3envsensorflowlibsite-packagesensorflowpythonkerasackend\__init__.py", line 22, in <module>
    from tensorflow.python.keras._impl.keras.backend import abs
ImportError: cannot import name 'abs'
(tensorflow) C:Usersice305ensorflowmodels
esearchobject_detection>

I don't understand what 'abs' is. Please help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This worked for me in ubuntu 18.0.4

pip uninstall tensorflow protobuf --yes
find $CONDA_PREFIX -name "tensorflow" | xargs -Ipkg rm -rfv pkg
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl --no-cache-dir

Solution found from GitHub: ImportError: cannot import name 'abs' #20778.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...