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
答案 0 :(得分:0)
Here是Github仓库,其中包含运行Deeplab的Colab笔记本。
我尚未对其进行测试,但是您将整个目录上传到Google云端硬盘的方式并不是在Colab上运行代码的正确方法。
将Colab视为一台单独的计算机,您正在将Google云端硬盘安装在此计算机上。您的Google云端硬盘上可用的任何内容不一定对Colab机器可用。您必须使用'\content\drive\My Drive\<path_to_your_folder>'
将Google Drive文件夹的路径(例如sys.path
添加到Colab机器的sys.path.insert(0, <path_of_your_drive_folder>)
中,以使该路径可用于Colab计算机上运行的python环境。
答案 1 :(得分:0)
解决了mt问题。不幸的是,abggcv提供的链接存储库遇到了这个问题所引用的同一问题。
您应该正常克隆存储库,然后正常运行所有内容。唯一的变化是,在运行train.py,eval.py或vis.py之前,您需要运行以下代码段:
%cd /root/deeplabvc/models/research/
import sys
sys.path.extend(['/root/deeplabvc/models/research/', '/root/deeplab/models/research/slim/'])
请注意,/root/deeplab/
是我克隆存储库的路径。如果克隆存储库的目录不同,则需要更改此设置。
此外,由于某些原因,您将无法连续运行train.py/eval.py/vis.py。即使清除标志也会给您带来关于重复标志的错误。要解决此问题,只需重新启动运行时(不会丢失文件)。
分割愉快!
答案 2 :(得分:0)
Deeplab导入错误主要是在PYTHONPATH
设置不正确时发生的。给出的安装说明不适用于COLAB环境。以下对我有用
%cd /content/deeplab/models/research/
!mkdir -p deeplab/datasets/pascal_voc_seg/exp/train_on_train_set/train
!mkdir -p deeplab/datasets/pascal_voc_seg/exp/train_on_train_set/eval
!mkdir -p deeplab/datasets/pascal_voc_seg/exp/train_on_train_set/vis
!echo ${PYTHONPATH}
%env PATH_TO_TRAIN_DIR=/content/deeplab/models/research/deeplab/datasets/pascal_voc_seg/exp/train_on_train_set/train
%env PATH_TO_DATASET=/content/deeplab/models/research/deeplab/datasets/pascal_voc_seg/tfrecord
%env PYTHONPATH=/content/deeplab/models/research:/content/deeplab/models/research/deeplab:/content/deeplab/models/research/slim:/env/python
!echo ${PYTHONPATH}
Here是我的COLAB笔记本,用于训练Deeplab并有效