-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathart_cor_medium_noise.py
More file actions
83 lines (63 loc) · 2.54 KB
/
art_cor_medium_noise.py
File metadata and controls
83 lines (63 loc) · 2.54 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import numpy as np
import torch
import matplotlib.pyplot as plt
from net import *
if __name__ == "__main__":
dev = torch.device('cuda:0')
anet = ArtNet(32, 64, 128, 128).to(dev)
anet.load_state_dict(torch.load("Networks/art_net_medium_noise.pth"))
anet.eval()
x_np = np.load("Recons/type_d_born_recon_medium_noise.npy")
y_np = 1.5*np.ones(x_np.shape)
nb = 5
for b in range(nb):
X = torch.from_numpy(x_np[b::nb,:,3:-3,3:-3]).to(dev)
Y = 1.5 + 0.1*anet(X)
Y = torch.clamp(Y, 1.4, 1.6)
y_np[b::nb,:,3:-3,3:-3] = Y.cpu().detach().numpy()
np.save("Recons/type_d_ac_recon_medium_noise.npy", y_np)
x_np = np.load("Recons/other_born_recon_medium_noise.npy")
y_np = 1.5*np.ones(x_np.shape)
nb = 40
for b in range(nb):
X = torch.from_numpy(x_np[b::nb,:,3:-3,3:-3]).to(dev)
Y = 1.5 + 0.1*anet(X)
Y = torch.clamp(Y, 1.4, 1.6)
y_np[b::nb,:,3:-3,3:-3] = Y.cpu().detach().numpy()
np.save("Recons/other_ac_recon_medium_noise.npy", y_np)
x_np = np.load("Recons/type_d_born_recon_low_noise.npy")
y_np = 1.5*np.ones(x_np.shape)
nb = 5
for b in range(nb):
X = torch.from_numpy(x_np[b::nb,:,3:-3,3:-3]).to(dev)
Y = 1.5 + 0.1*anet(X)
Y = torch.clamp(Y, 1.4, 1.6)
y_np[b::nb,:,3:-3,3:-3] = Y.cpu().detach().numpy()
np.save("Recons/type_d_ac_recon_medium_low.npy", y_np)
x_np = np.load("Recons/other_born_recon_low_noise.npy")
y_np = 1.5*np.ones(x_np.shape)
nb = 40
for b in range(nb):
X = torch.from_numpy(x_np[b::nb,:,3:-3,3:-3]).to(dev)
Y = 1.5 + 0.1*anet(X)
Y = torch.clamp(Y, 1.4, 1.6)
y_np[b::nb,:,3:-3,3:-3] = Y.cpu().detach().numpy()
np.save("Recons/other_ac_recon_medium_low.npy", y_np)
x_np = np.load("Recons/type_d_born_recon_high_noise.npy")
y_np = 1.5*np.ones(x_np.shape)
nb = 5
for b in range(nb):
X = torch.from_numpy(x_np[b::nb,:,3:-3,3:-3]).to(dev)
Y = 1.5 + 0.1*anet(X)
Y = torch.clamp(Y, 1.4, 1.6)
y_np[b::nb,:,3:-3,3:-3] = Y.cpu().detach().numpy()
np.save("Recons/type_d_ac_recon_medium_high.npy", y_np)
x_np = np.load("Recons/other_born_recon_high_noise.npy")
y_np = 1.5*np.ones(x_np.shape)
nb = 40
for b in range(nb):
X = torch.from_numpy(x_np[b::nb,:,3:-3,3:-3]).to(dev)
Y = 1.5 + 0.1*anet(X)
Y = torch.clamp(Y, 1.4, 1.6)
y_np[b::nb,:,3:-3,3:-3] = Y.cpu().detach().numpy()
np.save("Recons/other_ac_recon_medium_high.npy", y_np)