Skip to content

Commit

Permalink
fix h5py warning
Browse files Browse the repository at this point in the history
  • Loading branch information
lidq92 committed Nov 7, 2019
1 parent 9c65827 commit c26faaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(self, args, status='train', loader=default_loader):
self.n_patches = args.n_patches
self.loader = loader

Info = h5py.File(args.data_info)
Info = h5py.File(args.data_info, 'r')
index = Info['index']
index = index[:, args.exp_id % index.shape[1]]
ref_ids = Info['ref_ids'][0, :] #
Expand Down Expand Up @@ -165,8 +165,8 @@ def __init__(self, args, status='train', loader=default_loader):
self.scale = Info['subjective_scores'][0, :].max()
self.mos = Info['subjective_scores'][0, self.index] / self.scale #
self.mos_std = Info['subjective_scoresSTD'][0, self.index] / self.scale #
im_names = [Info[Info['im_names'][0, :][i]].value.tobytes()[::2].decode() for i in self.index]
ref_names = [Info[Info['ref_names'][0, :][i]].value.tobytes()[::2].decode()
im_names = [Info[Info['im_names'][0, :][i]][()].tobytes()[::2].decode() for i in self.index]
ref_names = [Info[Info['ref_names'][0, :][i]][()].tobytes()[::2].decode()
for i in (ref_ids[self.index]-1).astype(int)]

self.patches = ()
Expand Down Expand Up @@ -215,7 +215,7 @@ def __init__(self, args, status='train', loader=default_loader):
self.patch_size = args.patch_size
self.n_patches = args.n_patches

Info = h5py.File(args.data_info)
Info = h5py.File(args.data_info, 'r')
index = Info['index']
index = index[:, args.exp_id % index.shape[1]]
ref_ids = Info['ref_ids'][0, :] #
Expand Down Expand Up @@ -248,8 +248,8 @@ def __init__(self, args, status='train', loader=default_loader):
self.scale = Info['subjective_scores'][0, :].max()
self.mos = Info['subjective_scores'][0, self.index] / self.scale #
self.mos_std = Info['subjective_scoresSTD'][0, self.index] / self.scale #
im_names = [Info[Info['im_names'][0, :][i]].value.tobytes()[::2].decode() for i in self.index]
ref_names = [Info[Info['ref_names'][0, :][i]].value.tobytes()[::2].decode()
im_names = [Info[Info['im_names'][0, :][i]][()].tobytes()[::2].decode() for i in self.index]
ref_names = [Info[Info['ref_names'][0, :][i]][()].tobytes()[::2].decode()
for i in (ref_ids[self.index]-1).astype(int)]

self.patches = ()
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h5py==2.7.1
h5py==2.10.0
numpy==1.14.2
scipy==1.0.1
tensorflow-gpu==1.0.0
Expand Down
6 changes: 3 additions & 3 deletions test_cross_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@

model.load_state_dict(torch.load(args.model_file))

Info = h5py.File(args.names_info)
im_names = [Info[Info['im_names'][0, :][i]].value.tobytes()\
Info = h5py.File(args.names_info, 'r')
im_names = [Info[Info['im_names'][0, :][i]][()].tobytes()\
[::2].decode() for i in range(len(Info['im_names'][0, :]))]
ref_names = [Info[Info['ref_names'][0, :][i]].value.tobytes()\
ref_names = [Info[Info['ref_names'][0, :][i]][()].tobytes()\
[::2].decode() for i in (Info['ref_ids'][0, :]-1).astype(int)]

model.eval()
Expand Down

0 comments on commit c26faaf

Please sign in to comment.