openai / guided-diffusion

MIT License
5.9k stars 782 forks source link

file npz change to picture #105

Open GYiFeng opened 1 year ago

GYiFeng commented 1 year ago

Could you tell me how to change the 64_samples.npz file to picture?

lowestbuaaer commented 1 year ago

import numpy as np from PIL import Image
data = np.load('xxx.npz') k = 0 for i in data['arr_0']: if k%1000==0: print(k) img = Image.fromarray(i) img.save(str(k)+".jpg") k = k+1

zouyunpeng666 commented 1 year ago

从 PIL 导入 numpy 作为 np 导入 图像数据 = np.load('xxx.npz') k = 0 for i in data['arr_0']: 如果 k%1000==0: print(k) img = Image.fromarray(i) img.save(str(k)+“.jpg”) k = k+1

感谢,很有用