Skip to content

Commit da93b78

Browse files
committed
Final commit
1 parent ed0fbe1 commit da93b78

7 files changed

+8
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ You can install these dependencies using `pip install -r requirements.txt`
109109
```
110110
python datapreprocess.py \path\to\data\set \path\to\vocab\
111111
python train.py
112-
python train_justify.py
112+
python train_justify.py
113113
```
114114
#### Testing
115115
Download the pretrained models [checkpoint_d](https://drive.google.com/open?id=1w4zF82hgbPmU9hAHsY92myjOU6HYD_BI) and [checkpoint_j](https://drive.google.com/open?id=1QLyqU5HZHYAyRJTSsIBPqG8zARU0oZUL)

beamsearch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def beam_search_discriminative(encoder, decoder, image_path_t,image_path_d,lambd
417417
elif sys.argv[1]=="cj": ## cj Image_path target_class distractor class
418418
checkpoints=torch.load('checkpoint_j')
419419
encoder=checkpoints['encoder']
420-
decoder=checkpoints['decoder']
420+
decoder=checkpoints['decoder']
421421
encoder.eval()
422422
decoder.eval()
423423
image_path=sys.argv[2]

datapreprocess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import torchfile as tf
88
from PIL import Image
99
from matplotlib.pyplot import imshow
10-
import sys
10+
import sys
1111
cub_dataset = sys.argv[1] #'C:/Users/hello/Desktop/Accads/CUB_200_2011/' # Location of cub dataset
1212
captions_dataset= sys.argv[2] # 'C:/Users/hello/Desktop/Accads/cvpr2016_cub/word_c10/' # Location of captions dataset
1313
VocabSize=5725+1 # Starts from 1 and ends at 5725, include start token also

datasets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from torch.utils.data import Dataset
66
import h5py
77
import numpy as np
8-
8+
99
class CaptionDataset(Dataset):
1010
def __init__(self, transform):
1111
self.h = h5py.File('dataset.hdf5','r',driver='core')
@@ -14,7 +14,7 @@ def __init__(self, transform):
1414
self.captions= np.array(self.h['captions'])
1515
self.class_k =np.array(self.h['class'])
1616
self.maxcapslen=30+3
17-
self.numcaptions=self.h['numcaptions'].value
17+
self.numcaptions=self.h['numcaptions'].value
1818
self.transform=transform
1919

2020
def __getitem__(self, i):

models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def forward(self, images):
2121
out = out.permute(0,2,3,1) # Batch* d*e*e to batch*e*e*d, helps in attention
2222
return out
2323

24-
class Attention(nn.Module):
24+
class Attention(nn.Module):
2525
def __init__(self, encoder_dim, decoder_dim, attention_dim):
2626
super(Attention, self).__init__()
2727
self.encoder_att = nn.Linear(encoder_dim, attention_dim)

train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
dropout = 0.5 # Dropout rate
1515
decoder_lr = 2*1e-3 # Decoder learning rate
1616
numepochs=100 # Number of epochs
17-
load=False ## Make this false when you don't want load a checkpoint
17+
load=False ## Make this false when you don't want load a checkpoint
1818

1919
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
2020

train_justify.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
dropout = 0.5 # Dropout rate
1515
decoder_lr = 2*1e-3 # Decoder learning rate
1616
numepochs=100 # Number of epochs
17-
load=False ## Make this false when you don't want load a checkpoint
17+
load=False ## Make this false when you don't want load a checkpoint
1818

1919
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
2020

0 commit comments

Comments
 (0)