0

My model return 3 cordinate [x,y,angle]. I want TRE similarity between 2 images. My custom loss is:

loss(y_true, y_pred):

  s = tfa.image.rotate(images=y_true[0], angles=y_pred[0][0])
  s = tfa.image.translate(images=s, translations=y_pred[0][1:])
  s = tf.reduce_sum(tf.sqrt(tf.square(s-y_true[1])))

y_pred=(1, 3)->tensor with [angle,x,y]

y_true=(2,128,128)-> in y_true[0] and y_true[1]: image. I:

  • s=Rotate and translate y_true[0],
  • Compare s and y_true[1], with MSE

I can't use tfa.image.translate beacuse is not differentiable? How can rotate an image in a custom loss function? There are problem with gradient?

  • Welcome to Stackoverflow! Please [edit your question](https://stackoverflow.com/posts/70395804/edit) and make sure code is formatted as `code`, to avoid attracting downvotes. – zabop Dec 17 '21 at 16:30

1 Answers1

0

I Believe this will or will not work depending on the frequency distribution in your data. But in fft space this might be easier.

neworld
  • 3
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 01 '22 at 21:08