Working version. Training, updation, testing and writing binary image outputs done.