如何在Google Colab中显示文件夹中的图像 [英] How to show image from folder in google colab

查看:228
本文介绍了如何在Google Colab中显示文件夹中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Markdown单元格内联显示google colab中文件夹 figures 中的图片?

我的本​​地驱动器上具有以下笔记本结构.

 数字-pic1.png-pic2.png-...Notebook1.ipynbNotebook2.ipynb等等. 

在google colab中打开笔记本并上传了数字文件夹之后,我检查了包含图片的文件夹是否确实已上传.是的.

然后我在降价单元格中尝试了以下操作:

 ![Pic1](figures/pic1.png) 

这显然不适用于Google colab.

杰克·范德普拉斯(Jake VanderPlas)如何做到这一点

https://colab.research.google.com/drive/1jWHKR6rhhyZtUulttBD6Pxd_AJh>

关键位是 Image 显示帮助程序,已应用于本地文件–

来自IPython.display的

 图片('220px-TensorFlowLogo.svg.png') 

How can I show the pictures from folder figures in google colab inline in a markdown cell?

I have the following structure of notebooks on my local drive.

figures
    - pic1.png
    - pic2.png
    - ...
Notebook1.ipynb
Notebook2.ipynb
etc.

After opening a Notebook in google colab and uploading the figures folder, I checked that the folder with pictures is actually uploaded. It is.

I then tried the following in a markdown cell:

![Pic1](figures/pic1.png)

This apparently doesn't work in google colab.

How did Jake VanderPlas do this here? Apparently he didn't even upload the pictures into a folder "figures" but still uses the following line in markdown

![Broadcasting Visual](figures/02.05-broadcasting.png) in the above link (scroll down to see a picture on numpy arrays).

Any help is appreciated!

Thanks!

解决方案

GitHib image references are resolved relative to the repo.

For notebooks stored in Drive, you'll need to embed the image in the notebook. Here's an example:

https://colab.research.google.com/drive/1jWHKR6rhhyZtUulttBD6Pxd_AJhgtVaV

The key bit is the Image display helper, applied to a local file–

from IPython.display import Image
Image('220px-TensorFlowLogo.svg.png')

这篇关于如何在Google Colab中显示文件夹中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆