alexgkendall / SegNet-Tutorial

Files for a tutorial to train SegNet for road scenes using the CamVid dataset
http://mi.eng.cam.ac.uk/projects/segnet/tutorial.html
847 stars 517 forks source link

What arguments are required for webdemo.py #55

Open Maxfashko opened 7 years ago

Maxfashko commented 7 years ago

Hi, how to start webdemo.py ? I'm trying to run webdemo.py follows: python 'webcam_demo.py' --model SegNet-Tutorial/Models/segnet_inference.prototxt --weights SegNet-Tutorial/Models/Inference/test_weights.caffemodel --colours SegNet-Tutorial/Scripts/test/0_image.png I get the following error: File "webcam_demo.py", line 32, in <module> output_shape = net.blobs['argmax'].data.shape KeyError: 'argmax' What image should be submitted to the argument --colours ?

Simon-Prevoteaux commented 7 years ago

Hi,

I think your --colours arg is correct, it is a png image containing colored pixel of each class of the dataset.

However yout error suggest that you are not using the right inference model. You shold look at the end of this file segnet_inference.prototxt and you should see that the final layer is named prob.

Therefore you have to change the webcam_demo script like that :

output_shape = net.blobs['prob'].data.shape

You will also have to change it again further in the code and be carefull, the output of the network will be the probabily of each class and not the class. You can easily find it with np.argmax(prob,axis=0)

Hope that will help

energabos commented 7 years ago

@Simon-Prevoteaux how do I know which --colour arg is correct for my model?

Simon-Prevoteaux commented 7 years ago

Hi, I have to admit I haven't worked on Segnet for a long time, however if i remember well, you --colours arg should point to an image containing vertically aligned pixels. Each pixel colour will be used for one class. So for example, the first pixel will be for class 1, the second pixel for class 2 etc... For debug, you can use the images in the /script folder and load it with opencv, and try to reproduce it to fit your own model.