【问题标题】:How to unzip cats-vs-dogs data in kaggle?如何在 kaggle 中解压缩 cat-vs-dogs 数据?
【发布时间】:2020-03-09 06:44:46
【问题描述】:

这是我的第一个 kaggle 内核,我对 kaggle 中的事情很确定。 我尝试为猫狗分类器创建一个新内核。

那么,

!ls ../input/dogs-vs-cats/
# sampleSubmission.csv  test1.zip  train.zip

!unzip ../input/dogs-vs-cats/train.zip
# this gives a report that looks like it works.
# it displays jpg files names
# but when I check the folder train, it does not exits

!ls ../input/dogs-vs-cats/train/
# there is no folder train


import os
print(os.listdir("../input/dogs-vs-cats"))
# ['train.zip', 'test1.zip', 'sampleSubmission.csv']
# there is no unzipped folder

如何访问kaggle内核中的数据?

【问题讨论】:

  • 您确定尝试将目的地添加到解压缩命令吗?也许这与您可以编写内核的哪些部分有关。 !unzip ../input/dogs-vs-cats/train.zip . (注意末尾添加的点)
  • 你也可以试试:os.system('unzip ../input/dogs-vs-cats/*.zip')

标签: python kaggle


【解决方案1】:

您可以将 zip 文件加载到 pandas 中,

df = pd.read_csv('train.zip')
df

【讨论】:

    【解决方案2】:

    您在错误的位置查看解压缩文件。

    Instead of: 
    !unzip ../input/dogs-vs-cats/train.zip
    !ls ../input/dogs-vs-cats/train/
    
    Do this:
    !unzip ../input/dogs-vs-cats/train.zip
    !ls train/
    
    

    在 python 中检查

    import os
    print(os.listdir("train"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      相关资源
      最近更新 更多