2

I used Mask-RCNN and Tensorflow in a project. I have completed many trainings in the past.

In the recent one, I found loss curve having a large amplitude of shock in tensorboard. I changed some settings such as batch_size in a small range but it's useless(in my opinion).

I found that it's the first time using .png to train, used .jpg before this training, maybe something wrong here?

Thank you in advance.

Abu Noman Md Sakib
  • 322
  • 2
  • 5
  • 20
  • I answered your question below. I would appreciate and upvote and marking it as accepted answer or any other feedback. Thank you – Tim Jan 08 '20 at 13:29

1 Answers1

1

Of course, there is a difference between png and jpeg format. PNG supports lossless data compression, whereas JPEG uses always a lossy compression. Therefore the same image can become numerically different, if we save it in a different format.

Example:

We assume the following png image (make sure to download it, to reproduce this example). We will save this image as jpg and then we will compare the png image with the jpg image:

https://upload.wikimedia.org/wikipedia/commons/6/6c/Belton_Garden.png example png

Code:

import cv2
import numpy as np 

img = cv2.imread('./Belton_Garden.png',  -1)

img_png = img 
cv2.imwrite('./Belton_Garden.jpg', img)

img_jpg = cv2.imread('./Belton_Garden.jpg', -1)

diff = img_png - img_jpg
cv2.imwrite('diff.png', diff)
print('diff', diff)

The difference of the png and the jpg image looks like this:

diff

Conclusion:

Will different image formats (jpg, png) affect the training results of Mask-RCNN?

As you can see, it may affect your results. For this reason, it is a good idea to be consistent with the image format, to remove this source of error.

Tim
  • 10,459
  • 4
  • 36
  • 47