jonkhler / s2cnn

Spherical CNNs
MIT License
948 stars 175 forks source link

some question when I run gendata.py in /examples/mnist folder #38

Closed townblack closed 5 years ago

townblack commented 5 years ago

When I run gendata.py with no rotation in training data and test data with the command :

        python3 gendata.py --no_rotate_train --no_rotate_test                

And I visualize some results, but some images generated seem to has nothing to do with the original images. Some results are like these: Figure_1

Figure_2

Figure_3

I think the spherical images(right) are strange, there has nothing to do with the original images(left). I also test the algorithm on some other image: Figure_4

Obviously, there is something wrong with gendata.py, but I can not figure out what is wrong, so can you explain it?

jonkhler commented 5 years ago

I just ran it on my laptop. If I see it right, these "weird result" are just coming from the distortion introduced by the stereographic projection. As written in the paper, we compare two data sets: one in which each digit is projected on the northern hemisphere and one in which each projected digit is additionally randomly rotated (p.6). As the two coordinates of the spherical image correspond to polar and azimuth angle, a projection onto a pole must end up either in the top or the bottom of the image. For the digits this can introduce significant distortion (the whole point of the architecture ;-)), but if you closely inspect your weird images, they make a lot of sense (e.g. the topology of the 0 is wrapped around the pole, the "hole" of the 9 is clearly visible, as is the curves of the 3). If you inspect your own image, you can see that it just corresponds to the original image, just wrapped around one pole.

If you inspect randomly rotated images/digits (without the flags activated), you will recognize them easier in the cases where the random rotation of the grid rotation pushes them away from the poles. Then you will see pictures like those in figure 4 of the original paper. To test, that those images should indeed correspond to the original images, just wrapped around the pole of the sphere, you can rotate them (e.g. in fourier space as given in the examples) and see how they change according to changes of azimuth and polar angles.

EDIT: but I realize that the current version of the code must be indeed slightly different to the original version I used for generating the digits in the paper. If I remember correctly, the grid was already rotated in a way, such that the digit ends up at the central area of the spherical image. I will check for this and probably refactor the part to avoid confusion here as soon as I find time.l

townblack commented 5 years ago

Thanks a lot, Your explanation makes it clear for me to understand. I will have a try as you mentioned.

mariogeiger commented 5 years ago

59371395-79775880-8d77-11e9-828d-bdec7425208c

The center of the image (green dot) is mapped to the pole (green line). The four corners (other colored dots) are mapped to the equator.

townblack commented 5 years ago

Thank you very much! It helps me to understand the projection process.