如何将 github 存储库挂载为 google colab 中的当前目录文件夹?

how to mount a github repository as the current directory folder in google colab?

我目前正在从我的 Google 驱动器加载图像。

但问题是,这些图像在我的驱动器中,当我与其他人共享我的 colab 笔记本时,他们不能 运行 因为它需要我的身份验证代码才能访问驱动器图像。

所以我想如果我将数据文件夹上传到 Github 存储库并将该存储库设为 public 将允许任何人获取数据(在我的例子中是图像文件夹)。因此 运行 colab 代码不需要身份验证。

我不知道如何将目录挂载到 Github 存储库作为 Google 驱动器。

from google.colab import drive
drive.mount('/content/drive/') # this will set my  google drive folder as the notebook directory.

是否可以对 github 存储库进行类似的安装?

您可以通过 运行 git 在代码单元中像这样直接克隆存储库。

!git clone https://github.com/yourusername/yourpublicrepo.git

这将创建一个名为 yourpublicrepo 的文件夹。