Search code examples
tensorflowgoogle-colaboratorydeeplab

Setting up DeepLabV3 in colab


So I am trying to set up deeplab in colab.

I am running:

[1]

from google.colab import drive
drive.mount('/content/drive')
%cd /content/drive/My\ Drive/deeplab_files

[2]

%env PYTHONPATH=/content/drive/My\ Drive/deeplab_files/:/content/drive/My\ Drive/deeplab_files/slim
!echo $PYTHONPATH

[3]

!python deeplab/vis.py \
    --logtostderr \
    --vis_split="val" \
    --model_variant="xception_65" \
    --atrous_rates=6 \
    --atrous_rates=12 \
    --atrous_rates=18 \
    --output_stride=16 \
    --decoder_output_stride=4 \
    --vis_crop_size=360 \
    --vis_crop_size=480 \
    --dataset="camvid" \
    --colormap_type="pascal" \
    --checkpoint_dir='/content/drive/My\ Drive/deeplab_files/deeplab/datasets/PQR/exp/train_on_trainval_set/train' \
    --vis_logdir='/content/drive/My\ Drive/deeplab_files/deeplab/datasets/PQR/exp/train_on_trainval_set/vis' \
    --dataset_dir='/content/drive/My\ Drive/deeplab_files/deeplab/datasets/PQR/tfrecord'

The last command, however, returns

sh: 1: export: Drive/deeplab_files/slim:/content/drive/My Drive/deeplab_files/:/content/drive/My Drive/deeplab_files/slim: bad variable name
Traceback (most recent call last):
  File "deeplab/vis.py", line 28, in <module>
    from deeplab import common
ModuleNotFoundError: No module named 'deeplab'

Anyone have any idea how I can set up deeplab? I have it set up on my personal machine, but it is much too slow. I uploaded the entire folder to my gdrive.

The odd thing is that I can do

from deeplab import common

from the notebook and that imports successfully


Solution

  • Solved mt question. The linked repo that abggcv gave, unfortunately, runs into the same issue this question was citing.

    You should clone the repo as normal, and run everything as normal. The only change is that before you run train.py, eval.py, or vis.py you'll need to run the following block:

    %cd /root/deeplabvc/models/research/
    import sys
    sys.path.extend(['/root/deeplabvc/models/research/', '/root/deeplab/models/research/slim/'])
    

    Note that /root/deeplab/ is the path to where I cloned the repo. You'll need to change this if the directory where you cloned the repo is different.

    Furthermore, for some reason, you wont be able to run train.py/eval.py/vis.py successively. Even clearing the flags will give you an error about a duplicate flag. To fix this, just restart the runtime (wont lose your files).

    Happy segmenting!