cocolab使用教程
1 准备数据集
切换路径并用wget 下载coco和wikiart数据集,并用unzip解压数据集
%cd /content/drive/Shared\ drives/MySharedDrive/dataset
!pwd
!ls
!wget http://images.cocodataset.org/zips/train2017.zip
!wget http://web.fsktm.um.edu.my/~cschan/source/ICIP2017/wikiart.zip
!unzip train2017.zip
!unzip wikiart.zip
2 安装环境
根据python 版本以及cuda版本选择安装pytorch
查看python版本、cuda版本
!python --version
!nvcc --version
!nvidia-smi
根据版本安装
!pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
测试pytorch是否可以调用gpu
import torch
print(torch.cuda.is_available())
3 切换到项目路径
切换到项目路径
!pwd
%cd /content/drive/Shared\ drives/MySharedDrive/code/MAST
!pwd
!ls
3.1 训练
nohup python -u train_autoencoder.py --output_path ../../results/train/vgg_decoder_with_connection/cascade_connection/r41/exp2-cascade-weight-1e-7 --perceptual_loss_weight 1e-7 --batch_size 8 --layer_list r41 --content_layers r41,r31,r21,r11 --cascade_weight 1e-7 --gpu 0 > ../../log/train_vgg_with_skip_cascade_connection_r41-exp2-cascade-weight-1e-7.log 2>&1 &
3.2 测试
!ls
%cd /content/drive/Shared\ drives/MySharedDrive/code/MAST/test
!python test.py --gpu 0 --is_batch --output_path ../results/batch_test/exp1