-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yoonseo Kim
committed
Nov 27, 2020
1 parent
a30ac57
commit 4987141
Showing
11 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
data | ||
data | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import torch | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
from utils.dataloader import val_loader | ||
from models.medium import mediumNet | ||
from models.small import smallNet | ||
|
||
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" | ||
PATH = './trained_model/medium_74_128px.pth' | ||
|
||
# Our Dataset Classes | ||
classes = ('airplane', 'cat', 'dog', 'motorbike', 'person') | ||
|
||
model = mediumNet() | ||
trained_weight = torch.load(PATH, map_location='cpu') | ||
model.load_state_dict(trained_weight) | ||
|
||
def custom_imshow(imgList, predicted): | ||
|
||
fig = plt.figure() | ||
|
||
rows = 2 | ||
cols = 2 | ||
|
||
for i in range(4): | ||
img = imgList[i] | ||
temp = fig.add_subplot(rows, cols, i+1) | ||
temp.set_title(classes[predicted[i]]) | ||
temp.imshow(np.transpose(img, (1, 2, 0))) | ||
temp.axis('off') | ||
|
||
plt.show() | ||
|
||
for idx, data in enumerate(val_loader): | ||
|
||
inputs, labels = data | ||
outputs = model(inputs) | ||
_, predicted = torch.max(outputs.data, 1) | ||
|
||
custom_imshow(inputs, predicted) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters