-
Notifications
You must be signed in to change notification settings - Fork 48
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
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
test_demo_any.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we should use channel_means.npz
instead of channel_means1.npz
for compatibility with the current model settings.
test_demo_any.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please support multiple images in an image directory. A for loop will just work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks pinaxe1, no new pull request is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we can create a directory called custom_dir
for new images and their predictions specifically. Royalty-free images could be downloaded from Pixabay.
@@ -171,6 +172,12 @@ Image| Label | Prediction | | |||
:-------------------------:|:-------------------------:|:-------------------------: | |||
![](data/demos/deeplab/resnet_101_voc2012/image_3.jpg) | ![](data/demos/deeplab/resnet_101_voc2012/image_3_label.png) | ![](data/demos/deeplab/resnet_101_voc2012/image_3_prediction.png) | |||
|
|||
## Running demo on your own images:<br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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