iwyoo / tf_ThinPlateSpline

Thin Plate Spline Spatial Transformer Network implementation with TensorFlow
Apache License 2.0
72 stars 11 forks source link

confuesed #1

Closed wushilian closed 6 years ago

wushilian commented 6 years ago

V = ThinPlateSpline2(U, source, target, out_size) can you tell me the meaning of source and target?what's the meaning of these points?

iwyoo commented 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.

wushilian commented 6 years ago

@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?

iwyoo commented 6 years ago

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

wushilian commented 6 years ago

@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:

tim 20171122154001

mnist: mnist I save the trans data to image,but it's same as input

iwyoo commented 6 years ago

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.)

wushilian commented 6 years ago

@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?

wushilian commented 6 years ago

@iwyoo Can I get your email? thanks for your help!

iwyoo commented 6 years ago

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.

dp-isi commented 5 years ago

can you please tell what is relative coordinate here ?