-
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
Showing
10 changed files
with
56 additions
and
50 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,8 +1,10 @@ | ||
# Learned-SIFT-Descriptor | ||
HW6 for 16-720 | ||
# Prerequisites | ||
* MATLAB | ||
* Anaconda | ||
* PyTorch: conda install pytorch torchvision -c soumith | ||
|
||
# To run the code | ||
run testMatch.m | ||
|
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
from net1 import SiameseNetwork | ||
from torchvision import transforms | ||
from PIL import Image | ||
import torch | ||
from torch.autograd import Variable | ||
import scipy.io | ||
import time | ||
import numpy as np | ||
def compute_desc(): | ||
net=SiameseNetwork().cuda() | ||
|
||
net.load_state_dict(torch.load('model.pt')) | ||
net.train(False) | ||
# transform=transforms.ToTensor() | ||
imgs=scipy.io.loadmat('patch.mat')['patches'] | ||
N=len(imgs) | ||
mat=np.zeros([N-1,128]) | ||
for i in range(N-1): | ||
img=imgs[i] | ||
img=img.reshape(1,1,img.shape[0],img.shape[1]) | ||
X=torch.from_numpy(img) | ||
|
||
_,output=net(Variable(X.float()).cuda(),Variable(X.float()).cuda()) | ||
|
||
#print 'time:'+str(end-start) | ||
mat[i]=output.data.cpu().numpy() | ||
scipy.io.savemat('learned_desc.mat',mdict={'desc':mat}) | ||
# print mat.tolist() | ||
return 0 | ||
if __name__ == "__main__": | ||
compute_desc() | ||
|
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
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