Google Colab - 无法上传大数据文件

问题描述 投票:0回答:1

使用 Google Colab 中的上传功能,我无法将大型(约 2.4 GB)图像分割模型文件 (sam_vit_h_4b8939.pth) 从本地计算机上传到 Google Colab。我可以看到它在“文件”窗格中以红色圆圈列出,但在等待大约 10 分钟后,我取消了上传。此外,我在选择“内容”文件夹的情况下发出了“上传”命令,但该文件和另一个文件最初松散地列在顶级文件夹中。我能够成功上传不同的文件(.zip 格式的图像数据)并将其拖到内容文件夹中。 Colab 虚拟硬盘上显示有足够的空间。

尝试将大文件上传到Google Colab并期望能够成功。相反,文件要么被拒绝,要么上传超时,没有任何错误消息。

更新 1:我注意到我在 Google Colab 中处理的 Jupyter 笔记本的单元格 1 中出现以下错误消息:“连接到 dl.fbaipublicfiles.com (dl.fbaipublicfiles.com)|13.226.210.111|:443...连接的。 HTTP 请求已发送,正在等待响应... 403 Forbidden 2024-01-17 21:18:52 错误 403:禁止。”

显然,模型文件不是从 facebookresearch/segment-anything 存储库上传的;然而,我随后尝试将此文件从我的本地计算机上传到 Google Colab,但没有成功。

更新2:我通过上传较小的分割模型(sam_vit_b_01ec64.pth)解决了这个问题。

file-upload google-colaboratory
1个回答
0
投票

在 SAM github 上的 automatic_mask_generator_example.ipynb 文件中,如果 using_colab 为 true,则有单元格

if using_colab:
    import torch
    import torchvision
    print("PyTorch version:", torch.__version__)
    print("Torchvision version:", torchvision.__version__)
    print("CUDA is available:", torch.cuda.is_available())
    import sys
    !{sys.executable} -m pip install opencv-python matplotlib
    !{sys.executable} -m pip install 'git+https://github.com/facebookresearch/segment-anything.git'

    !mkdir images
    !wget -P images https://raw.githubusercontent.com/facebookresearch/segment-anything/main/notebooks/images/dog.jpg

    !wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth

每当我运行此单元时,它都会成功获取 vit_h 模型。或者,我建议将 pth 文件上传到您的驱动器,然后将其安装并导入到 colab 单元中:

from google.colab import drive
drive.mount('/content/drive')
© www.soinside.com 2019 - 2024. All rights reserved.