【问题标题】:Importing COCO datasets to google colaboratory将 COCO 数据集导入 google colaboratory
【发布时间】:2019-08-28 15:08:49
【问题描述】:

COCO 数据集非常大,我可以将其上传到 google colab。有什么办法可以直接将数据集下载到google colab?

【问题讨论】:

  • 您好,欢迎来到 SO,您能否提供更多详细信息,例如什么是“非常大”以及重现您的问题的其他步骤。此外,包含您所看到内容的更多详细信息的屏幕截图也可以提供帮助
  • 大约 20GB,包括训练、测试和验证数据集。我想将 cocodasets.org 中的数据集直接导入我的 Google colab notebook。

标签: python computer-vision google-colaboratory semantic-segmentation


【解决方案1】:

你可以直接用wget下载

!wget http://images.cocodataset.org/zips/train2017.zip

另外,您应该使用提供更大空间的 GPU 实例(350 GB)。

【讨论】:

  • 我想知道为什么谷歌没有在 colab 中提供这些数据集。他们在浪费大量资源,因为这个数据集可能每天要加载数千次到 colab。
  • @subjord google keras api 有预先训练好的模型,他们不打扰的原因
【解决方案2】:

另一种方法是仅将 annotations file 上传到 Google Colab。无需下载图像数据集。我们将使用PyCoco API。接下来,在准备图像时,您可以通过 URL 读取图像文件,而不是从 Drive / local 文件夹中访问图像文件!

# The normal method. Read from folder / Drive
I = io.imread('%s/images/%s/%s'%(dataDir,dataType,img['file_name']))

# Instead, use this! Url to load image
I = io.imread(img['coco_url'])

此方法将为您节省大量空间、下载时间和精力。但是,您在训练期间需要有效的 Internet 连接来获取图像(当然您有,因为您使用的是 colab)。

如果您对使用 COCO 数据集感兴趣,可以查看my post on medium。

【讨论】:

    【解决方案3】:

    您可以将其下载到谷歌驱动器,然后将驱动器安装到 Colab。

    from google.colab import drive
    drive.mount('/content/drive')
    

    然后您可以 cd 到包含数据集的文件夹,例如。

    import os
    os.chdir("drive/My Drive/cocodataset")
    

    【讨论】:

    • coco占用多少空间?驱动器应该付费订阅吗?
    【解决方案4】:

    使用驱动器更适合进一步使用。还要使用 colab ( !unzip ) 解压缩 zip,因为在驱动器上使用 zip 提取器需要更长的时间。我试过了:D

    【讨论】:

      【解决方案5】:

      如今,下载 COCO 最简单的方法是使用 Python 工具,fiftyone。它让你download, visualize, and evaluate the dataset as well as any subset你感兴趣。

      它也是works directly in Colab,因此您可以在那里执行整个工作流程。

      import fiftyone as fo
      import fiftyone.zoo as foz
      
      #
      # Only the required images will be downloaded (if necessary).
      # By default, only detections are loaded
      #
      
      dataset = foz.load_zoo_dataset(
          "coco-2017",
          splits=["validation","train"],
          classes=["person", "car"],
          # max_samples=50,
      )
      
      # Visualize the dataset in the FiftyOne App
      session = fo.launch_app(dataset)
      

      【讨论】:

        猜你喜欢
        • 2018-04-09
        • 2018-08-15
        • 2019-04-24
        • 2018-07-13
        • 2018-07-06
        • 1970-01-01
        • 2019-08-06
        • 1970-01-01
        • 2021-03-28
        相关资源
        最近更新 更多