NPE.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Neural-Photo-Editor 作者: ajbrock 项目源码 文件源码
def update_photo(data=None,widget=None):
    global Z
    if data is None: # By default, assume we're updating with the current value of Z
        data = np.repeat(np.repeat(np.uint8(from_tanh(model.sample_at(np.float32([Z.flatten()]))[0])),4,1),4,2)
    else:
        data = np.repeat(np.repeat(np.uint8(data),4,1),4,2)

    if widget is None:
        widget = output
    # Reshape image to canvas
    mshape = (4*64,4*64,1)
    im = Image.fromarray(np.concatenate([np.reshape(data[0],mshape),np.reshape(data[1],mshape),np.reshape(data[2],mshape)],axis=2),mode='RGB')

    # Make sure photo is an object of the current widget so the garbage collector doesn't wreck it
    widget.photo = ImageTk.PhotoImage(image=im)
    widget.create_image(0,0,image=widget.photo,anchor=NW)
    widget.tag_raise(pixel_rect)

# Function to update the latent canvas.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号