Skip to content

Commit

Permalink
fixed the cases when the input files are not 310x310 in gradcam predi…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
lext committed Feb 27, 2019
1 parent a541896 commit f937798
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ the file with the bounding boxes, which determine the locations of the knees in
**NOTE:** the image of the left knee will be horizontally flipped to match the right one.
4. Produce the file with KL gradings of the extracted knee images:
```
$ cd own_codes
$ cd ouludeepknee/own_codes
$ python inference_own/predict.py --help
$ python inference_own/predict.py {parameters}
$ cd ..
Expand Down
10 changes: 7 additions & 3 deletions ouludeepknee/own_codes/produce_gradcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ def load_picture(self, fname, nbits=16):
else:
raise TypeError

width, height = img.size

if width != 310 or height != 310:
img = img.resize((310, 310), Image.BICUBIC)
cropper = CenterCrop(300)

l, m = get_pair(cropper(img))
Expand Down Expand Up @@ -315,6 +319,7 @@ def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('--path_folds', default=SNAPSHOTS_KNEE_GRADING)
parser.add_argument('--path_input')
parser.add_argument('--nbits', type=int, default=16)
parser.add_argument('--path_output', default='../')

args = parser.parse_args()
Expand All @@ -336,9 +341,8 @@ def parse_args():

paths_test_files = glob(os.path.join(config.path_input, '*', '*.png'))

if not os.path.exists(config.path_output):
os.makedirs(config.path_output)
os.makedirs(config.path_output, exist_ok=True)

for path_test_file in tqdm(paths_test_files, total=len(paths_test_files)):
net.predict_save(fileobj_in=path_test_file, nbits=16,
net.predict_save(fileobj_in=path_test_file, nbits=config.nbits,
path_dir_out=config.path_output)

0 comments on commit f937798

Please sign in to comment.