-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_freyfaces.py
47 lines (40 loc) · 1.2 KB
/
view_freyfaces.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytorch_lightning as pl
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import TensorBoardLogger
from pytorch_lightning.callbacks import EarlyStopping
from pytorch_lightning.callbacks import LearningRateMonitor
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.callbacks import EarlyStopping
# read mat file
import scipy.io as sio
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn import init
import numpy as np
import math
from torch.optim import Adam
import torch
import numpy as np
matfile = sio.loadmat('./cs/data/frey_rawface.mat')
faces = matfile['ff'].T.reshape(-1, 28, 20)
print(matfile.keys())
print(matfile['ff'].shape)
print(faces.shape)
print(faces.dtype)
# show two faces
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
# imgplot = plt.imshow(faces[0,:,:], cmap='gray')
# plt.show()
# imgplot = plt.imshow(faces[100,:,:], cmap='gray')
# plt.show()
for i in range(25):
plt.subplot(5, 5, i+1)
plt.imshow(faces[i*80,:,:], cmap='gray')
plt.axis('off')
plt.show()