Skip to content

Commit

Permalink
feat(models): save best performing model.
Browse files Browse the repository at this point in the history
  • Loading branch information
saeranv committed May 6, 2021
1 parent 0646a38 commit c7dc4f4
Show file tree
Hide file tree
Showing 275 changed files with 847 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ data/ghout/
data/traintest/
data/traintest_small/
data/hbjsons/
data/
*.sql
*.whl

Binary file modified data/gh/bem_model_serialize.gh
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed data/traintest_small/out_data/0_out_floorplan_1.jpg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed data/traintest_small/out_data/1_out_floorplan_10.jpg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
37 changes: 27 additions & 10 deletions deeprad/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ def __init__(self, device, f1=16, k1=3):
# TODO: add nonlinear layer?
self.encoder = nn.Sequential( # like the Composition layer you built
nn.Conv2d(6, f1, k1, stride=2, padding=1),
nn.ReLU(),
nn.LeakyReLU(),
nn.Conv2d(f1, f2, k1, stride=2, padding=1),
nn.ReLU(),
nn.LeakyReLU(),
nn.Conv2d(f2, f3, k2),
nn.ReLU(),
nn.LeakyReLU(),
nn.Conv2d(f3, f4, k2)
)

# TODO: add softmax?
self.decoder = nn.Sequential(
nn.ConvTranspose2d(f4, f3, k2),
nn.ReLU(),
nn.LeakyReLU(),
nn.ConvTranspose2d(f3, f2, k2),
nn.ReLU(),
nn.LeakyReLU(),
nn.ConvTranspose2d(f2, f1, k1, stride=2, padding=1, output_padding=1),
nn.ReLU(),
nn.LeakyReLU(),
nn.ConvTranspose2d(f1, 3, k1, stride=2, padding=1, output_padding=1),
# nn.Sigmoid()
# nn.Tanh
nn.Sigmoid()
#nn.LeakyReLU()#,nn.Tanh
)

def forward(self, x):
Expand Down Expand Up @@ -96,7 +96,7 @@ def __len__(self):

def __getitem__(self, idx):
"""Load image from directory given index."""
crop_x, crop_y = 0, 0
crop_x, crop_y = 0, 9
crop_w, crop_h = 1300, 108

img_loc = os.path.join(self.main_dir, self.total_imgs[idx])
Expand All @@ -108,12 +108,29 @@ def __getitem__(self, idx):
channel_1 = Image.open(ch1_loc).convert("RGB")
channel_2 = Image.open(ch2_loc).convert("RGB")

# Ccrop inputs
# Crop inputs
image = image.crop((crop_x, crop_y, crop_x + crop_w, crop_y + crop_h))
channel_1 = channel_1.crop((crop_x, crop_y, crop_x + crop_w, crop_y + crop_h))
channel_2 = channel_2.crop((crop_x, crop_y, crop_x + crop_w, crop_y + crop_h))

# crop
# image = np.array(image)[crop_x: crop_w, crop_y : crop_h]
# channel_1 = np.array(channel_1)[crop_x: crop_w, crop_y: crop_h]
# channel_2 = np.array(channel_2)[crop_x: crop_w, crop_y: crop_h]

x_in = torch.cat((self.transform(channel_1), self.transform(channel_2)), dim=0)
y_lbl = self.transform(image)

#x_in = x_in.int()
#y_lbl = y_lbl.int()

del image; del channel_1; del channel_2; del img_loc; del ch1_loc; del ch2_loc

# import matplotlib.pyplot as plt
# y_lbl = y_lbl.permute(1, 2, 0)
# print(y_lbl.size())
# plt.imshow(y_lbl)
# plt.show()
# assert False

return x_in, y_lbl
9 changes: 5 additions & 4 deletions deeprad/traintest_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ def viz_loss(outputs, img_fpath, img_title='Radiation Map', xdim=10, show_plot=F
label = label_batch[0].permute(1, 2, 0).detach().cpu().numpy()
recon = recon_batch[0].permute(1, 2, 0).detach().cpu().numpy()

label = clean_img4rad(label) / 255.0 * 1000.0
recon = clean_img4rad(recon) / 255.0 * 1000.0
#recon = np.clip(recon, 0.0, 255.0).astype(int)
#label = clean_img4rad(label) / 255.0 * 1000.0
#recon = clean_img4rad(recon) / 255.0 * 1000.0

im = a[i, 0].imshow(label, cmap=RADCMAP, vmin=0, vmax=1000)
im = a[i, 1].imshow(recon, cmap=RADCMAP, vmin=0, vmax=1000)
im = a[i, 0].imshow(label)#, cmap=RADCMAP, vmin=0, vmax=1000)
im = a[i, 1].imshow(recon)#, cmap=RADCMAP, vmin=0, vmax=1000)
clean_plot4rad(a[i], i)

# left, bottom, width, height
Expand Down
Binary file added models/df/result_df.pkl
Binary file not shown.
7 changes: 7 additions & 0 deletions models/model_20210506-021606/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
last test_loss: [0.00660582]
test_loss: [[0.01389268]
[0.01008498]
[0.0077674 ]
[0.00787939]
[0.00660582]]
training time: h:0 m:1 s:51
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions models/model_20210506-022043/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
last test_loss: [0.00773177]
test_loss: [[0.0122387 ]
[0.01925329]
[0.0078491 ]
[0.00681292]
[0.00626831]
[0.00594877]
[0.00793488]
[0.00554319]
[0.00509024]
[0.00522656]
[0.00500392]
[0.00489696]
[0.00436793]
[0.00448514]
[0.02440766]
[0.03817239]
[0.0262886 ]
[0.0252372 ]
[0.02446845]
[0.0243717 ]
[0.02449455]
[0.01615284]
[0.00932975]
[0.00845786]
[0.00773177]]
training time: h:0 m:8 s:40
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-023823/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.00513484]
test_loss: [[0.00642225]
[0.00560506]
[0.00556434]
[0.00479162]
[0.0046627 ]
[0.04009283]
[0.04007641]
[0.04005576]
[0.04014063]
[0.04008703]
[0.04004154]
[0.04007852]
[0.04013837]
[0.02287525]
[0.00850873]
[0.00756035]
[0.00628676]
[0.00609663]
[0.00540932]
[0.00513484]]
training time: h:0 m:6 s:50
Binary file added models/model_20210506-023823/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-024801_sigmoid/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.0404136]
test_loss: [[0.00650297]
[0.0053346 ]
[0.00474136]
[0.00477508]
[0.00434636]
[0.00424521]
[0.00429393]
[0.00397451]
[0.04043235]
[0.0403258 ]
[0.04043892]
[0.04049728]
[0.04043292]
[0.04052813]
[0.04037973]
[0.04040314]
[0.0404946 ]
[0.04049032]
[0.04046083]
[0.0404136 ]]
training time: h:0 m:7 s:2
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-050120/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.00376571]
test_loss: [[0.00873717]
[0.00700724]
[0.00624093]
[0.00582324]
[0.00537704]
[0.0051421 ]
[0.00510931]
[0.00479073]
[0.00481021]
[0.00461175]
[0.00460752]
[0.00441033]
[0.00426731]
[0.00414414]
[0.00410547]
[0.00397599]
[0.00416182]
[0.00390747]
[0.00391987]
[0.00376571]]
training time: h:0 m:6 s:24
Binary file added models/model_20210506-050120/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-051200/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.02439159]
test_loss: [[0.03420103]
[0.0104777 ]
[0.00815089]
[0.00744235]
[0.04022742]
[0.03240201]
[0.03220778]
[0.02471894]
[0.0401059 ]
[0.016645 ]
[0.04021125]
[0.01480315]
[0.04021156]
[0.02495696]
[0.0243977 ]
[0.02427862]
[0.02544884]
[0.02419577]
[0.02415112]
[0.02439159]]
training time: h:0 m:6 s:20
Binary file added models/model_20210506-051200/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-051826/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.03064372]
test_loss: [[0.03112303]
[0.03063456]
[0.03069884]
[0.03070091]
[0.03061627]
[0.03071266]
[0.0305542 ]
[0.03053091]
[0.03065423]
[0.03053825]
[0.0308224 ]
[0.03061396]
[0.03060174]
[0.0306754 ]
[0.03061336]
[0.03056623]
[0.0306121 ]
[0.03075451]
[0.03055138]
[0.03064372]]
training time: h:0 m:6 s:19
Binary file added models/model_20210506-051826/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-052451/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.02997749]
test_loss: [[0.03164007]
[0.03017076]
[0.03005473]
[0.0300474 ]
[0.03000421]
[0.03003434]
[0.03004317]
[0.03003589]
[0.03015953]
[0.03005943]
[0.03008069]
[0.02997419]
[0.03001923]
[0.03005805]
[0.03004132]
[0.03004277]
[0.03012958]
[0.03010974]
[0.03015311]
[0.02997749]]
training time: h:0 m:6 s:25
Binary file added models/model_20210506-052451/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions models/model_20210506-053123/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
last test_loss: [0.03180446]
test_loss: [[0.03527263]
[0.03267101]
[0.03195613]
[0.0317746 ]
[0.03181642]
[0.0318057 ]
[0.03175871]
[0.03171796]
[0.03176349]
[0.03180444]
[0.03173973]
[0.03176798]
[0.03174742]
[0.0317592 ]
[0.03175276]
[0.03180073]
[0.03171606]
[0.03195552]
[0.03178935]
[0.03180446]]
training time: h:0 m:6 s:22
Binary file added models/model_20210506-053123/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions models/model_20210506-060128/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
max_epochs: 15
batch_size: 5
learning_rate: 0.00184
weight_decay: 0.00020957
f1: 24
k1: 3
last test_loss: [0.04059655]
test_loss: [[0.00800483]
[0.00658701]
[0.00608908]
[0.00532129]
[0.00491463]
[0.00481828]
[0.00657785]
[0.0059823 ]
[0.00486277]
[0.00470289]
[0.04054457]
[0.04050905]
[0.04055 ]
[0.04051444]
[0.04059655]]
training time: h:0 m:4 s:44
Binary file added models/model_20210506-060128/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions models/model_20210506-061202/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
max_epochs: 15
batch_size: 5
learning_rate: 0.000203228544324115
weight_decay: 1.2697111322756407e-05
f1: 24
k1: 3
last test_loss: [0.00490871]
test_loss: [[0.00942542]
[0.00807117]
[0.00709147]
[0.00658547]
[0.00698589]
[0.00593312]
[0.00584494]
[0.00567217]
[0.00546132]
[0.00539046]
[0.00525101]
[0.00515217]
[0.00513384]
[0.00503964]
[0.00490871]]
training time: h:0 m:4 s:59
Binary file added models/model_20210506-061202/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions models/model_20210506-062306/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
max_epochs: 15
batch_size: 5
f1: 24
k1: 3
learning_rate: 0.000203228544324115
weight_decay: 1.2697111322756407e-05
last test_loss: [0.00422964]
test_loss: [[0.00936869]
[0.00714576]
[0.00647498]
[0.00589099]
[0.00558233]
[0.00531443]
[0.00520697]
[0.00507637]
[0.0048417 ]
[0.0047039 ]
[0.00455466]
[0.00477791]
[0.00449089]
[0.00430649]
[0.00422964]]
training time: h:0 m:5 s:30
Binary file added models/model_20210506-062306/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions models/model_20210506-062842/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
max_epochs: 15
batch_size: 5
f1: 32
k1: 3
learning_rate: 0.000203228544324115
weight_decay: 1.2697111322756407e-05
last test_loss: [0.00387622]
test_loss: [[0.00859414]
[0.00679519]
[0.00610648]
[0.00558913]
[0.00518311]
[0.00500454]
[0.00476132]
[0.00464809]
[0.00440924]
[0.0043967 ]
[0.00450505]
[0.00418117]
[0.00400594]
[0.00394423]
[0.00387622]]
training time: h:0 m:6 s:1
Binary file added models/model_20210506-062842/learning_curve.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions models/model_20210506-063449/hparams.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
max_epochs: 15
batch_size: 5
f1: 64
k1: 3
learning_rate: 0.000203228544324115
weight_decay: 1.2697111322756407e-05
Loading

0 comments on commit c7dc4f4

Please sign in to comment.