Closed wushilian closed 6 years ago
For example, assume that you want to make a warp that drags point 1 (p1) to point 2. Then, in this case, p1 is source and p2 is target. STN uses relative coordinates. As in the README files,
s_ = np.array([ # source position
[-0.5, -0.5],
[0.5, -0.5],
[-0.5, 0.5],
[0.5, 0.5]])
t_ = np.array([ # target position
[-0.3, -0.3],
[0.3, -0.3],
[-0.3, 0.3],
[0.3, 0.3]])
The square of scale 0.3 is dragged to 0.5. Therefore, the circle in 'transformed2.png' is swollen.
@iwyoo ,thanks,do you mean souce is an constant,target can change?If I want use TPS in cnn,I should regress the target rather than source?
If you give a constant tensor as a source, then it is a constant. Source and target both can be constant or variable. There is more simpler implementation https://github.com/iwyoo/TPS_STN-tensorflow
@iwyoo thanks,in fact,I use this code in classfication task(rotated mnist),but it seems like the image didn't change after TPS,my code is like below:
mnist: I save the trans data to image,but it's same as input
Is classification being trained well? You need to check values of 'loc' tensor. If training is not going well, you need to decrease number of control points (now it looks 20. However, even the original STN paper uses 4x4=16 control points.)
@iwyoo ss_ = np.array([ # source position [-1, -1], [1, -1], [-1, 0], [0, 1]])
t_ = np.array([ # target position [-1, -1], [1, -1], [-1, 1], [1, 1]]) Use this points to transform image,the output image is the top half of the original image?
@iwyoo Can I get your email? thanks for your help!
You can mail me iwyoo@unist.ac.kr For the question, no. To move top half, source and target should be, source : [-1, -1], [-1, 1], [1, -1], [1, 1] target : [-1, -1], [-1, 0], [1, -1], [1, 0]
It is easy to understand if you think about transformation that pulls target's points to the position of source.
can you please tell what is relative coordinate here ?
V = ThinPlateSpline2(U, source, target, out_size) can you tell me the meaning of source and target?what's the meaning of these points?