sacmehta / ESPNet

ESPNet: Efficient Spatial Pyramid of Dilated Convolutions for Semantic Segmentation
https://sacmehta.github.io/ESPNet/
MIT License
541 stars 112 forks source link

Allow overlaying predicted mask onto the original image #12

Closed frk2 closed 6 years ago

frk2 commented 6 years ago

First of all THANK YOU FOR THIS!

This really helps visualize how effective the network is during / after training so you get output like the following

c_af962335-00000000

sacmehta commented 6 years ago

You can do it easily as shown below. Let me know if it makes sense and then I can merge it.

change 1 (after line 70)

img_orig = copy.deepcopy(img)

change 2 (after line 101)

if args.colored: classMap_numpy_color = PILImage.fromarray(classMap_numpy) classMap_numpy_color.putpalette(pallete) classMap_numpycolor.save(args.savedir + os.sep + 'c' + name.replace(args.img_extn, 'png')) if args.overlay: classMap_numpy_color = numpy.array(classMap_numpy_color) overlayed = cv2.addWeighted(img_orig, 0.5, classMap_numpycolor, 0.5,0) cv2.imwrite(args.savedir + os.sep + 'over' + name.replace(args.img_extn, 'jpg'), overlayed)

frk2 commented 6 years ago

I'm cool with anything if it produces the above image :laughing:

  1. img_orig will still need to be resized if the input images are of diff sizes
  2. Unclear how addWeighted works - classMap_numpy_color has a lot of black pixels in it (undetected region)
sacmehta commented 6 years ago

I have added an overlay option which will produce an output similar to below image. Please have a look. Sorry for late response.

over_frankfurt_000000_000576_leftimg8bit

frk2 commented 6 years ago

Nice. Thanks 🙇

On Tue, Jul 3, 2018, 7:42 PM Sachin Mehta notifications@github.com wrote:

I have added an overlay option which will produce an output similar to below image. Please have a look.

[image: over_frankfurt_000000_000576_leftimg8bit] https://user-images.githubusercontent.com/18603245/42253953-18728dbc-7ef9-11e8-8764-eb390807e148.jpg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sacmehta/ESPNet/pull/12#issuecomment-402346689, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCMYuUIMJuV14O7Lw1QupB9Gr4lB8SJks5uDCt7gaJpZM4U43Bu .