datawhalechina / vced

VCED 可以通过你的文字描述来自动识别视频中相符合的片段进行视频剪辑。该项目基于跨模态搜索与向量检索技术搭建,通过前后端分离的模式,帮助你快速的接触新一代搜索技术。

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

运行教程2的markdown中的示例代码出错

Ethan-Chen-plus opened this issue · comments

image
这段切割大型图像的代码,报错如下。
image
修改建议

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 绘制成图片集图片