运行教程2的markdown中的示例代码出错
Ethan-Chen-plus opened this issue · comments
from jina import Document
d = Document(uri='complicated-image.jpeg')
d.load_uri_to_image_tensor()
print(d.tensor.shape)
d.convert_image_tensor_to_sliding_windows(window_shape=(64, 64)) # 使用 64*64 的滑窗切割原图像,切分出 12*15=180 个图像张量
print(d.tensor.shape)
# 可以通过 as_chunks=True,使得上述 180 张图片张量添加到 Document 块中。
# PS:运行这行代码时,需要重新 load image tensor,否则会报错。
d.load_uri_to_image_tensor()
d.convert_image_tensor_to_sliding_windows(window_shape=(64, 64), as_chunks=True)
print(d.chunks)
d.chunks.plot_image_sprites('simpsons-chunks.png') # 使用 plot_image_sprites 将各个 chunk 绘制成图片集图片