Skip to content

Commit

Permalink
added instructions for scoring single image
Browse files Browse the repository at this point in the history
  • Loading branch information
malteprinzler committed Nov 17, 2020
1 parent 0731462 commit abe0740
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 25 deletions.
112 changes: 90 additions & 22 deletions notebooks/attribute_prediction.ipynb

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions python_code/iMatDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,11 @@ def __init__(self, labels_file, img_dir, attr_descr_file, image_augmentations=li
self.img_dir = img_dir

# getting labels
with open(labels_file, "r") as f:
self.labels = json.load(f)["annotations"]
if labels_file and os.path.exists(labels_file):
with open(labels_file, "r") as f:
self.labels = json.load(f)["annotations"]
else:
self.labels = []

###
# Transformations
Expand All @@ -206,7 +209,8 @@ def __init__(self, labels_file, img_dir, attr_descr_file, image_augmentations=li

self.attr_descr = self.get_attribute_description(attr_descr_file)
self.n_attrs = len(self.attr_descr)
self.len = (length if length is not None else min(len(self.labels), len(os.listdir(self.img_dir))))
self.len = (length if length is not None else min(len(self.labels),
len(os.listdir(self.img_dir)) if self.img_dir else 0))

def __getitem__(self, item):
"""
Expand Down

0 comments on commit abe0740

Please sign in to comment.