如何通过相关笔记本中的URL访问Google云端硬盘或google-colaboratory中的图像文件

时间:2019-05-22 15:05:58

标签: url google-colaboratory

在colab笔记本中,我需要在训练后用几个(叠加的)图像创建一个html。 我已将Google驱动器映射为与之协作:

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

因此,我可以例行创建,读取和写入图像,以及在google-drive和google-colab之间进行复制。

但是,我无法通过url访问图像。例如,这不起作用:

from IPython.core.display import display, HTML
display(HTML('<img src="/content/gdrive/My Drive/elmo_1.jpg">'))

我虽然是由于“我的驱动器”中的空间而尝试插入%20,但仍然无法正常工作。实际上,即使以前将其存储在colab上,我也无法访问该图像(因此,路径中没有空格,图像会被复制但无法访问):

!cp "/content/gdrive/My Drive/Colab/elmo_1.jpg" "/content"
display(HTML('<img src="/content/elmo_1.jpg">'))

预先感谢您的见解。

0 个答案:

没有答案