Skip to content

Commit

Permalink
train with own co-occurrence matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-amrahd committed Apr 23, 2020
1 parent c98c6d7 commit 698dd41
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
venv
*.pyc
data/yolov3.weights
__pycache__
Binary file added Results/model.pth
Binary file not shown.
Binary file removed Results/model_old.pth
Binary file not shown.
Binary file removed data/coco_adj.pkl
Binary file not shown.
Binary file removed data/coco_glove_word2vec.pkl
Binary file not shown.
20 changes: 0 additions & 20 deletions test_pickle.py

This file was deleted.

4 changes: 0 additions & 4 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataset import CocoDataset
from torch.utils.data import DataLoader
import pickle
from utils import generate_adjacency_matrix
import numpy as np

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
Expand All @@ -21,9 +20,6 @@
val_path = '/home/user/Data/coco2014/val2014'
val_ann_file = '/home/user/Data/coco2014/annotations/instances_val2014.json'

# adj = pickle.load(open('data/coco_adj.pkl', 'rb'))
# adj = np.float32(generate_adjacency_matrix(adj))

adj = pickle.load(open('adj.pickle', 'rb'))
adj = np.float32(adj / np.max(adj) + np.identity(num_classes))

Expand Down
20 changes: 0 additions & 20 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,3 @@ def tensor_to_image(img_tensor):
# img = np.clip(img, 0, 1)
return img


def generate_adjacency_matrix(adj_file):
nums = adj_file['nums']
adj = adj_file['adj']

nums = nums[:, np.newaxis]

adj = adj / nums

adj[adj < 0.5] = 0
adj[adj >= 0.5] = 1

adj = adj * 0.25 / (np.sum(adj, axis=0, keepdims=True) + 1e-6)
A = adj + np.identity(80, np.int)

D = np.power(np.sum(A, axis=1), -0.5)
D = np.diag(D)

adj = np.matmul(np.matmul(A, D).T, D)
return adj

0 comments on commit 698dd41

Please sign in to comment.