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 segmentation testing and support CPU #888

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions scripts/segmentation/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def test(args):
im_paths = dsts
predicts = evaluator.parallel_forward(data)
for predict, impath in zip(predicts, im_paths):
predict = mx.nd.squeeze(mx.nd.argmax(predict[0], 1)).asnumpy() + \
predict = mx.nd.squeeze(mx.nd.argmax(predict[0], 0)).asnumpy() + \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the standard practice, we use the first dimension as Batch dimension by default. Could you please still use dim=1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it. : )

testset.pred_offset
mask = get_color_pallete(predict, args.dataset)
outname = os.path.splitext(impath)[0] + '.png'
mask.save(os.path.join(outdir, outname))

if __name__ == "__main__":
args = parse_args()
args.test_batch_size = args.ngpus
args.test_batch_size = max(1, args.ngpus)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to know why args.test_batch_size here is dependent on args.ngpus. Also since args.batch_size is already defined, is it possible to use this one directly instead of adding a new one like test_batch_size?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review! I have removed this line, and I will update the code later.
The test_batch_size is defined in train.py, and it is the batch size of testing dataset. For testing script, we should keep the consistency with training procedure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review! I have removed this line, and I will update the code later.
The test_batch_size is defined in train.py, and it is the batch size of testing dataset. For testing script, we should keep the consistency with training procedure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why the program gets stuck. I will check it later.

print('Testing model: ', args.resume)
test(args)
2 changes: 2 additions & 0 deletions scripts/segmentation/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def parse_args():
# the parser
args = parser.parse_args()
# handle contexts
if args.ngpus == 0:
args.no_cuda = True
if args.no_cuda:
print('Using CPU')
args.kvstore = 'local'
Expand Down