Python 在Google Colab中尝试其他源图像后出现ValueError

Python 在Google Colab中尝试其他源图像后出现ValueError,python,numpy,google-colaboratory,valueerror,Python,Numpy,Google Colaboratory,Valueerror,所以最近,我一直在尝试Aliaksandr Siarohin的一阶运动模型方法来制作deepfake视频(使用与使用Google Colab/笔记本电脑类似的演示) 一切都进行得很顺利,直到我决定制作第二个deepfake视频,这次使用了不同的“源图像”(参见代码中的002.jpg)。更改源映像后,我遇到以下ValueError: ValueError:所有输入数组的维度数必须相同,但索引0处的数组有2个维度,索引1处的数组有3个维度 问题显然出在第33行: im=plt.imshow(np.c

所以最近,我一直在尝试Aliaksandr Siarohin的一阶运动模型方法来制作deepfake视频(使用与使用Google Colab/笔记本电脑类似的演示)

一切都进行得很顺利,直到我决定制作第二个deepfake视频,这次使用了不同的“源图像”(参见代码中的002.jpg)。更改源映像后,我遇到以下ValueError:

ValueError:所有输入数组的维度数必须相同,但索引0处的数组有2个维度,索引1处的数组有3个维度

问题显然出在第33行:

im=plt.imshow(np.concatenate(cols,axis=1),animated=True)

代码:

事实上,我在使用另一个映像成功运行代码后出现了这个错误,这让我认为问题在于映像。我再次尝试了第一个图像(001.jpg),但是ValueError没有出现。所以我的问题是,为了使给定的代码能够工作,我需要对图像进行哪些更改?或者代码本身有什么奇怪之处?我检查了文件大小(12KB),实际上它比我以前使用的文件小(31KB)。宽度和高度之间也没有太大的距离(新图像为218x300,旧图像为384x512)

!pip install scikit-video
import skvideo.io  
driving_video = skvideo.io.vread("/content/gdrive/My Drive/first-order-motion-model/huhu.mp4") 
print(driving_video.shape)

import imageio
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from skimage.transform import resize
from IPython.display import HTML
import warnings
warnings.filterwarnings("ignore")

source_image = imageio.imread('/content/gdrive/My Drive/first-order-motion-model/002.jpg')

#Resize image and video to 256x256

source_image = resize(source_image, (256, 256))[..., :3]
driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]

def display(source, driving, generated=None):
    fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))

    ims = []
    for i in range(len(driving)):
        cols = [source]
        cols.append(driving[i])
        if generated is not None:
            cols.append(generated[i])
        im = plt.imshow(np.concatenate(cols, axis=1), animated=True)
        plt.axis('off')
        ims.append([im])

    ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)
    plt.close()
    return ani
    

HTML(display(source_image, driving_video).to_html5_video())