[Small tool] Colab use

1 About Google Chrome

There are many situations in which access errors will be encountered during use . You only need to add an extension of Google Accessor Assistant to use the browser normally.
Insert picture description here

2 Drive

2.1 Create your own Google account

You can use Drive only if you create your own Google account. The URL is as follows
Insert picture description here

2.2 Add Colaboratory

The first time you use it, it will not appear in the right button, you can add it by linking more apps

Insert picture description here

2.3 Complete project upload

Create a new project folder first, as shown in the figure below

Insert picture description here
Insert picture description here

3 use

3.1 Enter the uploaded folder

Right click to enter and
Insert picture description here
change to GPU use
Insert picture description here

3.2 Test in sequence according to the following code

# -*- coding: utf-8 -*-
"""Untitled0.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1QP8_FMpefsO7GkGNLyNcdcwAE5hylY7k
"""

!nvidia-smi
#链接到服务器中
#
from google.colab import drive
drive.mount('/content/gdrive')

'''导入项目的文件'''
#test_20190905:就是项目的文件
import os
os.chdir("/content/gdrive/My Drive/ColabDir/test_20190905")

#查看设备环境
!pwd

#执行某个文件的方式
!python bg_img_loader.py

!python sample.py

!python detect_cnnNet.py

from PIL import Image
from IPython.display import Image as IMG
path = "yellow/1.png"
display(IMG(path))

3.3 Unzip the package

Reposted from https://www.cnblogs.com/jiangshengyin/p/13337049.html

3.3.1 Unzip rar

!pip install pyunpack
!pip install patool
from pyunpack import Archive
Archive('/content/drive/My Drive/NTS_Net.rar').extractall('/content/Keras-NTS-Net')

3.3.2 Unzip the zip

!unzip '/content/drive/My Drive/NTS_Net.rar' '/content/Keras-NTS-Net'

3.3.3 Another decompression method

Transfer from https://blog.csdn.net/zhangdongren/article/details/106237170

# 首先安装googledrivedownloader
pip install googledrivedownloader
#接着下载解压
from google_drive_downloader import GoogleDriveDownloader as gdd
gdd.download_file_from_google_drive(file_id='1uojI7wX5IYBSFBJGpgurTK5ySUXNu9Xv',
                                    dest_path='./data/faces.zip',
                                    unzip=True)

file_id:
file_id='1uojI7wX5IYBSFBJGpgurTK5ySUXNu9Xv:
is my share id of the file on Google Cloud Disk, for example, my share link is https://drive.google.com/open?id=1uoTKI7wX5IYBSFBJGpgurTK5ySUXNu9Xv_7wX5ySUXNu9Xv_id .
dest_path:
dest_path='./data/faces.zip' is the directory where the decompressed files are located, which is the destination path.

Guess you like

Origin blog.csdn.net/qq_43586192/article/details/113917981