If the train.txt does not have a \n (new line) at the end of the file, the program will crash and not finish. In other words, without this fix, we assume that there always is a \n after every line. This might not be the case for the last line of the file, dependent on how the train.txt file was made.
Instead of slicing the new line out of the current line, we instead remove all new lines by the using .replace(). Thus, we only have to worry about switching from .jpg/.png/other to .txt. Before, we had to worry about there being a .jpg\n/.png\n/other\n.
It has been adjusted and tested on my custom dataset, and it now works as I think was intended.
If the train.txt does not have a \n (new line) at the end of the file, the program will crash and not finish. In other words, without this fix, we assume that there always is a \n after every line. This might not be the case for the last line of the file, dependent on how the
train.txt
file was made.Instead of slicing the new line out of the current line, we instead remove all new lines by the using
.replace()
. Thus, we only have to worry about switching from.jpg/.png/other
to.txt
. Before, we had to worry about there being a.jpg\n/.png\n/other\n
.It has been adjusted and tested on my custom dataset, and it now works as I think was intended.