简体   繁体   English

谷歌 colab 错误使用谷歌驱动器中的文件

[英]Google colab error to use files from google drive

So to use files from google drive in google colab I used this code:因此,要在 google colab 中使用来自 google drive 的文件,我使用了以下代码:

from google.colab import drive
drive.mount('/content/gdrive')
!ln -s /content/gdrive/My\ Drive/ /mydrive
!ls /mydrive

Drive already mounted at /content/gdrive; to attempt to forcibly remount, call drive.mount("/content/gdrive", force_remount=True).
 app  'Colab Notebooks'   lixo  'My Drive'   pixellib   yolov3

Inside of pixellib I have the folder meat and the file pretraining.h5 .在 pixellib 我有文件meat和文件pretraining.h5

I installed this too:我也安装了这个:

!pip3 install pixellib

Until here, ok, but when I run this code:直到这里,好的,但是当我运行这段代码时:

import pixellib
from pixellib.custom_train import instance_custom_training

    train_maskrcnn = instance_custom_training()
    train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes= 2, batch_size = 4)
    train_maskrcnn.load_pretrained_model("/mydrive/pixellib/pretraining.h5")
    train_maskrcnn.load_dataset("/mydrive/pixellib/meat")
    train_maskrcnn.train_model(num_epochs = 20, augmentation=True,  path_trained_models = "/mydrive/pixellib/mask_rcnn_models")

the following error message appears:出现以下错误消息:

Using resnet101 as network backbone For Mask R-CNN model
---------------------------------------------------------------------------
IsADirectoryError                         Traceback (most recent call last)
<ipython-input-44-8a3b66f50c89> in <module>()
      7 train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes= 2, batch_size = 4)
      8 train_maskrcnn.load_pretrained_model("/mydrive/pixellib/pretraining.h5")
----> 9 train_maskrcnn.load_dataset("/mydrive/pixellib/meat")
     10 train_maskrcnn.train_model(num_epochs = 20, augmentation=True,  path_trained_models = "/mydrive/pixellib/mask_rcnn_models")

7 frames
/usr/local/lib/python3.6/dist-packages/PIL/Image.py in open(fp, mode)
   2807 
   2808     if filename:
-> 2809         fp = builtins.open(filename, "rb")
   2810         exclusive_fp = True
   2811 

IsADirectoryError: [Errno 21] Is a directory: '/mydrive/pixellib/meat/train/78-3.jpg'

What kind of error is that?那是什么样的错误? Something is wrong with my code?我的代码有问题吗?

If you have a json for every image in this directory (he said this in a comment), it seems likely to me that one of your json files has a.jpg ending.如果您对此目录中的每个图像都有 json(他在评论中说),那么在我看来,您的 json 文件中的一个文件可能以 .jpg 结尾。 Either download both json and jpg and confirm that they are the correct file type, or you try to plot the image instead to see if it is an image.要么下载 json 和 jpg 并确认它们是正确的文件类型,要么尝试 plot 图像而不是查看它是否是图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM