A script to run prediction on any (unlabeled) image. And some small addition to Utils.#7
Conversation
Added Test on any unlabeled image. Couple extra checks and a function added to Utils.
|
Thank you very much. I will review shortly. |
leimao
left a comment
There was a problem hiding this comment.
I tested the custom demo script for arbitrary image, and it works well after some slight modifications. Please modify the script slightly based on my comment so that I will approve the merge. In addition, do also include some arbitrary images. I was using this image for test. Please also add brief guidance on how to use this script in the README.md for the public. Thank you very much for your contribution.
| model_filename = 'resnet_101_0.6959.ckpt' | ||
| image_filename='data/datasets/MyImg/JPEGImages/00.jpg' | ||
|
|
||
| channel_means = save_load_means(means_filename='channel_means1.npz',image_filenames=None, recalculate=False) |
There was a problem hiding this comment.
Here we should use channel_means.npz instead of channel_means1.npz for compatibility with the current model settings.
| demo_dir = 'data/demos/deeplab/MyImg/' | ||
| models_dir = 'data/models/deeplab/resnet_101_voc2012/' | ||
| model_filename = 'resnet_101_0.6959.ckpt' | ||
| image_filename='data/datasets/MyImg/JPEGImages/00.jpg' |
There was a problem hiding this comment.
Please support multiple images in an image directory. A for loop will just work.
There was a problem hiding this comment.
I've done changes you proposed and committed in my repo. How do I proceed? Should I create a new pull request? (Sorry I' m new to github :)
There was a problem hiding this comment.
Thanks pinaxe1, no new pull request is required.
leimao
left a comment
There was a problem hiding this comment.
Thank you very much for the contribution. I tested your program and it ran fine. I provided some suggestions and comments on the code. Please let me know if you have time or you are willing to further modify. Otherwise, I will just accept the pull request, and probably modify by my own in the near future, if I can find some time :) You attention and effort are appreciated.
| files = glob(demo_dir+'*.jpg') | ||
| for image_filename in files: | ||
| filename=osp.basename(image_filename).split('.')[0] | ||
| image = read_image(image_filename=image_filename) |
There was a problem hiding this comment.
read_image uses OpenCV which does support multiple different image formats. We should not restrict the image format to jpg.
| deeplab = DeepLab('resnet_101', training=False) | ||
| deeplab.load(osp.join(models_dir, model_filename)) | ||
| files = glob(demo_dir+'*.jpg') | ||
| for image_filename in files: |
There was a problem hiding this comment.
Try to use trange from tqdm to get progress bar. I believe you will like it.
|
|
||
| if __name__ == '__main__': | ||
|
|
||
| demo_dir = 'data/demos/deeplab/resnet_101_voc2012/' |
There was a problem hiding this comment.
Probably we can create a directory called custom_dir for new images and their predictions specifically. Royalty-free images could be downloaded from Pixabay.
| :-------------------------:|:-------------------------:|:-------------------------: | ||
|  |  |  | ||
|
|
||
| ## Running demo on your own images:<br> |
There was a problem hiding this comment.
I am revising it slightly here.
Custom Demo
Just put some images into custom_dir and run the following command in the terminal:
$ python test_any_image.py
Results will be written into same folder. Make sure that proper model trained and a checkpoint is saved in models_dir. See the script for details.
|
|
||
| if __name__ == '__main__': | ||
|
|
||
| demo_dir = 'data/demos/deeplab/resnet_101_voc2012/' |
There was a problem hiding this comment.
The best way to do this with some customized arguments is probably to use argparse. Check some examples such as my train.py.
I think it would be the best course of actions. Because I'm more into quick dirty hacks than a proper programming :( You may put this requirements into ToDo so maybe someone (or even me) will make those sooner than you. :) |
I will accept the merge request then. Thank you very much for the contribution! |
Thank You. I greatly appreciate this DeepLab implementation of yours. It is really neat and clean and well documented. Thank You wery much. W.B.R. Paul. |
Added a function Single_demo to Utils to perform prediction on unlabeled images.
Added test_any_img script for same purpose.
WBR Paul