Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some rename bug #1

Merged
merged 3 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion data/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def __init__(self, root, txt, transform=None):
self.transform = transform
with open(txt) as f:
for line in f:
self.img_path.append(os.path.join(root, line.split()[0]))
if line.startswith('/'):
self.img_path.append(root + line.split()[0])
else:
self.img_path.append(os.path.join(root, line.split()[0]))
self.labels.append(int(line.split()[1]))

def __len__(self):
Expand Down
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

config = source_import(args.config).config
training_opt = config['training_opt']
relatin_opt = config['relations']
# change
relatin_opt = config['memory']
dataset = training_opt['dataset']

if not os.path.isdir(training_opt['log_dir']):
Expand All @@ -49,7 +50,7 @@
batch_size=training_opt['batch_size'],
sampler_dic=sampler_dic,
num_workers=training_opt['num_workers'])
for x in (['train', 'val', 'train_plain'] if relatin_opt['init_centers'] else ['train', 'val'])}
for x in (['train', 'val', 'train_plain'] if relatin_opt['init_centroids'] else ['train', 'val'])}

training_model = model(config, data, test=False)

Expand Down
2 changes: 1 addition & 1 deletion models/MetaEmbeddingClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def forward(self, x, centroids, *args):
dist_cur = torch.norm(x_expand - centroids_expand, 2, 2)
values_nn, labels_nn = torch.sort(dist_cur, 1)
scale = 10.0
confidence = (scale / values_nn[:, 0]).unsqueeze(1).expand(-1, feat_size)
reachability = (scale / values_nn[:, 0]).unsqueeze(1).expand(-1, feat_size)

# computing memory feature by querying and associating visual memory
values_memory = self.fc_hallucinator(x)
Expand Down
2 changes: 1 addition & 1 deletion models/ResNet10Feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def create_model(use_selfatt=False, use_fc=False, dropout=None, stage1_weights=False, dataset=None, test=False, *args):

print('Loading Scratch ResNet 10 Feature Model.')
resnet10 = ResNet(BasicBlock, [1, 1, 1, 1], use_selfatt=use_selfatt, use_fc=use_fc, dropout=None)
resnet10 = ResNet(BasicBlock, [1, 1, 1, 1], use_modulatedatt=use_selfatt, use_fc=use_fc, dropout=None)

if not test:
if stage1_weights:
Expand Down
4 changes: 2 additions & 2 deletions models/ResNet152Feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
def create_model(use_selfatt=False, use_fc=False, dropout=None, stage1_weights=False, dataset=None, caffe=False, test=False):

print('Loading Scratch ResNet 152 Feature Model.')
resnet152 = ResNet(Bottleneck, [3, 8, 36, 3], use_selfatt=use_selfatt, use_fc=use_fc, dropout=None)
resnet152 = ResNet(Bottleneck, [3, 8, 36, 3], use_modulatedatt=use_selfatt, use_fc=use_fc, dropout=None)

if not test:

Expand All @@ -13,7 +13,7 @@ def create_model(use_selfatt=False, use_fc=False, dropout=None, stage1_weights=F
if caffe:
print('Loading Caffe Pretrained ResNet 152 Weights.')
resnet152 = init_weights(model=resnet152,
weights_path='./logs/caffe_resnet152.pth',
weights_path='./logs/resnet152.pth',
caffe=True)
elif stage1_weights:
assert(dataset)
Expand Down