forked from pclubiitk/model-zoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval.py
27 lines (21 loc) · 751 Bytes
/
eval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
import torchvision.transforms as transforms
import torchvision
import matplotlib.pyplot as plt
import imageio
import os
def plot_loss(g_loss,d_loss,outdir):
plt.plot(g_loss, label='Generator_Losses')
plt.plot(d_loss, label='Discriminator Losses')
plt.legend()
plt.show()
plt.savefig(os.path.join(outdir,'loss.png'))
return
to_image = transforms.Compose([transforms.ToPILImage(),transforms.Resize((500,500))])
def make_gif(generator,images,outdir):
imgs = [np.array(to_image(i)) for i in images]
imageio.mimsave(outdir+"progress.gif", imgs)
return
def show_generator(generator,noise):
to_image(torchvision.utils.make_grid(generator(noise).reshape(-1,1,28,28).cpu().detach()))
return