tensorflow/model library source code Deeplabv3+ implementation (1)

1. Computer configuration

1.ubuntu16.04
2.anaconda3+python3.6+tensorflow1.5 (the version is too low)
3.CPU 4GB

2. Basic environment configuration

GIthub official installation link
I did not download Jupyter notebook

DeepLab depends on the following libraries:

    Numpy
    Pillow 1.0
    tf Slim (which is included in the "tensorflow/models/research/" checkout)
    Jupyter notebook
    Matplotlib
    Tensorflow

3.clone tensorflow/models

Clone the official models. I used anaconda to create a virtual environment called tensorflow. tensorflow is installed in the virtual environment, so I need to move the downloaded models to /home/hy/anaconda3/envs/tensorflow/lib/python3. 6/site-packages/tensorflow (this is my installation path, modified according to actual conditions)

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

Add dependent libraries to PYTHONPATH

gedit ~/.bashrc
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
source ~/.bashrc

Test model_test.py
All filename_test.py files in tensorflow/model are used to test whether the environment required by filename.py is correct.
local_test.sh tests whether the entire related deeplab, training VOC2012 data set code can run normally, the default is Xception network.
If your graphics card performance is not good, you can only use the CPU, you can use local_test_mobilenetv2.sh.

cd anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/models/research/(没错,目录很长)
python deeplab/model_test.py

Unsurprisingly, something went wrong
ERROR1

import tensorflow.compat.v1 as tf
ModuleNotFoundError: No module named ‘tensorflow.compat’

It may be that the tensorflow version is too low. Solution
Method 1: Upgrade tensorflow to 2.0
. This upgrade method used on the Internet does not matter if you use
pip install --ignore-installed --upgrade --ignore-installed tensorflow

pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.14.0rc0-cp36-cp36m-linux_x86_64.whl 

This is how I upgrade tensorflow1.5 version, corresponding to python3.6, should
only need to modify the tensorflow version and python version (the method has not been tried yet)
Method 2: Use the old version of the models
download link: https://pan. baidu.com/s/1X0B4HuRmusWeSO3391xZYw Extraction code: icua
ubuntu16 seems to be unable to install Baidu network disk, use aria2 to download ubuntu installation use aria2 to download Baidu network disk content -> Please note that following the reference link will make an error, just change to Type a space in the D1 of the command running in the background. But the download is still not successful, you can only go to the windows system to download and copy it over. If there is a shortcut, please leave me a message! ! !
After decompression, put it in a certain directory, for example, I put it in anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow (it doesn’t feel necessary to put it in a virtual environment, otherwise every time I enter the directory, Long, I found out only after configuring it).
Then run model_test.py. Note that if you use anaconda, you must start the virtual environment before running.

Then I encountered the second error
ERROR2

from nets.mobilenet import mobilenet_v2
ModuleNotFoundError: No module named ‘nets’

Solution
Reference: https://blog.csdn.net/u013249853/article/details/100089276
Enter the slim directory and enter:

python setup.py build
 
python setup.py install

Finally succeeded, the following results appeared:


Ran 5 tests in 16.902s
OK

--------------------------2020.4.13 update-------------------- ------------
Hit!
The models downloaded in the Baidu network disk are tensorflow110 version or higher, anyway tensorflow1.5 version is still too low, so I created a virtual environment and installed tensorflow1.14!
By mistake, I executed python setup.py build python setup.py install in the models/research directory to solve the error of no deeplab module.

Guess you like

Origin blog.csdn.net/qq_43265072/article/details/105440768
Recommended