【问题标题】:Zeppelin image display with base64 encoded content instead of HTML conversionZeppelin 图像显示使用 base64 编码内容而不是 HTML 转换
【发布时间】:2016-12-21 22:46:37
【问题描述】:

我目前正在使用 Zeppelin 和 Seaborn 进行一些可视化,但是显示机制会自动将图像转换为 HTML,这会立即占用我所有的 RAM。 (数据点太多)。

另一方面,Jupyter 处理起来相当容易,看起来它只是将图像内容编码为 Base64 字符串。

是否可以在 Zeppelin 中模仿这种行为?或者,更好的是,将其配置为默认的图像处理机制?

【问题讨论】:

    标签: apache-zeppelin


    【解决方案1】:

    我不知道我是否可以覆盖默认行为,但这可以通过 html 魔术手动实现。例如:

    def show(graphics):
        graphics.savefig("../tmp.png")
        with open("../tmp.png", "rb") as image_file:
            encoded_string = base64.b64encode(image_file.read())
        return """%html <img src="data:image/png;base64,{}" />""".format(encoded_string.decode())
    

    使用 base64 编码的 png 返回 html 字符串对我的数据来说效率更高,我可能会在任何地方使用它。

    【讨论】:

      猜你喜欢
      • 2015-11-22
      • 1970-01-01
      • 2014-03-28
      • 1970-01-01
      • 2017-04-24
      • 2023-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多