ax[1].set_title('Trainset error = {:.2e}'.format(trainset_error), fontsize=fs) ax[1].axes.xaxis.set_ticks([]) #set_xticklabels([]) ax[1].axes.yaxis.set_ticks([]) #set_yticklabels([]) ax[1].set_xlabel('$e$ = {:.2e} PSNR = {:.2f}'.format(trainimage_error, psnrscore), fontsize=fs) filename = "Just Generator/minerrortest" + timestamp + ".png" fig.savefig(filename, bbox_inches='tight') trainimages = testTheseImages(train_LRimages, model) print(train_HRimages[0].shape) trainset_error = sum([ np.mean(np.sqrt((i - j)**2)) for i, j in zip(trainimages, train_HRimages) ]) / len(trainimages) print(trainset_error) trainset_error = sum( [lf.smooth_l1(i, j) for i, j in zip(trainimages, train_HRimages)]) / len(trainimages) print(trainset_error) testimages = testTheseImages(test_LRimages, model) testset_error = sum( [np.mean(np.sqrt((i - j)**2)) for i, j in zip(testimages, test_HRimages)]) / len(testimages) print(testset_error) testset_error = sum( [lf.smooth_l1(i, j) for i, j in zip(testimages, test_HRimages)]) / len(testimages) print(testset_error)
testindex = 4 ax[2].imshow(test_HRimages[testindex], cmap='gray') ax[2].set_title("Input from test set", fontsize=fs) ax[2].axis('off') testimage = testThisImage(test_LRimages[testindex], model) testimage_error = np.mean((testimage - test_HRimages[testindex])**2) psnrscore = psnr(test_HRimages[testindex].astype(np.float), testimage.astype(np.float)) testimages = testTheseImages(test_LRimages, model) testset_error = sum( [np.mean((i - j)**2) for i, j in zip(testimages, test_HRimages)]) / len(testimages) print(testset_error) print( sum([lf.smooth_l1(i, j) for i, j in zip(testimages, test_HRimages)]) / len(testimages)) ax[3].imshow(testimage, cmap='gray') ax[3].set_title('Testset error = {:.2e}'.format(testset_error), fontsize=fs) ax[3].axes.xaxis.set_ticks([]) #set_xticklabels([]) ax[3].axes.yaxis.set_ticks([]) #set_yticklabels([]) ax[3].set_xlabel('$e$ = {:.2e} PSNR = {:.2f}'.format(testimage_error, psnrscore), fontsize=fs) # average = torch.zeros(HR_dim, HR_dim) # for HiResIm, LoResIm in zip(HR_loader, LR_loader): # average += HiResIm.mean(0) fig.subplots_adjust(wspace=0.01, hspace=0.01)