通过运行安装驱动器后,我正在使用 Google Colaboratory IPython 进行样式转换:
from google.colab import drive
drive.mount('/drive')
Run Code Online (Sandbox Code Playgroud)
它已挂载,所以我尝试 cd 进入一个目录,显示密码和 ls 但它没有显示正确的密码
!cd "/content/drive/My Drive/"
!pwd
!ls
Run Code Online (Sandbox Code Playgroud)
但它不会 cd 到给定的目录中,它只会 cd 到 'content/'
同样,当我尝试在我的代码中使用“load_image() 函数访问一些图像时,如下所示
def load_image(img_path, max_size=400, Shape=None):
image = Image.open(img_path).convert('RGB')
if max(image.size) > max_size:
size = max_size
else:
size = max(image.size)
if shape is not None:
size = shape
in_transform = transforms.Compose([transforms.Resize(size),
transforms.ToTensor(),
transforms.Normalize((0.485, 0.456, 0.406),
(0.229, 0.224, 0.225))])
image = in_transform(image)[:3,:,:].unsqueeze(0)
return image
#load image content
content = load_image('content/drive/My Drive/uche.jpg')
style = load_image('content/drive/My Drive/uche.jpg') …Run Code Online (Sandbox Code Playgroud)