Skip to content

Commit

Permalink
>
Browse files Browse the repository at this point in the history
  • Loading branch information
fregu856 committed Sep 23, 2018
1 parent e2bcb70 commit 2ce03f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions eval_on_val.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# camera-ready if everything works (need to modify paths)
# camera-ready if everything works

from datasets import DatasetVal # (this needs to be imported before torch, because cv2 needs to be imported before torch for some reason)
from deeplabv3 import DeepLabV3
Expand All @@ -21,11 +21,11 @@

batch_size = 8

network = DeepLabV3("eval_val", project_dir="/staging/frexgus/multitask").cuda()
network.load_state_dict(torch.load("/staging/frexgus/multitask/training_logs/model_13_2_2/checkpoints/model_13_2_2_epoch_573.pth"))
network = DeepLabV3("eval_val", project_dir="/root/deeplabv3").cuda()
network.load_state_dict(torch.load("/root/deeplabv3/pretrained_models/model_13_2_2_2_epoch_580.pth"))

val_dataset = DatasetVal(cityscapes_data_path="/datasets/cityscapes",
cityscapes_meta_path="/staging/frexgus/cityscapes/meta")
val_dataset = DatasetVal(cityscapes_data_path="/root/deeplabv3/data/cityscapes",
cityscapes_meta_path="/root/deeplabv3/data/cityscapes/meta")

num_val_batches = int(len(val_dataset)/batch_size)
print ("num_val_batches:", num_val_batches)
Expand All @@ -34,7 +34,7 @@
batch_size=batch_size, shuffle=False,
num_workers=4)

with open("/staging/frexgus/cityscapes/meta/class_weights.pkl", "rb") as file: # (needed for python3)
with open("/root/deeplabv3/data/cityscapes/meta/class_weights.pkl", "rb") as file: # (needed for python3)
class_weights = np.array(pickle.load(file))
class_weights = torch.from_numpy(class_weights)
class_weights = Variable(class_weights.type(torch.FloatTensor)).cuda()
Expand Down Expand Up @@ -80,7 +80,7 @@
overlayed_img = 0.35*img + 0.65*pred_label_img_color
overlayed_img = overlayed_img.astype(np.uint8)

cv2.imwrite("/staging/frexgus/multitask/training_logs/model_eval/" + img_id + "_overlayed.png", overlayed_img)
cv2.imwrite(network.model_dir + "/" + img_id + "_overlayed.png", overlayed_img)

val_loss = np.mean(batch_losses)
print ("val loss: %g" % val_loss)
Binary file added pretrained_models/model_13_2_2_2_epoch_580.pth
Binary file not shown.

0 comments on commit 2ce03f7

Please sign in to comment.