def snapshot_segdis(model, discriminator, valoader, epoch, best_miou, best_eiou, snapshot_dir, prefix): # miou = val(model,valoader) miou, eiou = val_e(model, valoader) snapshot = {'epoch': epoch, 'state_dict': model.state_dict(), 'miou': miou} snapshot_dis = { 'epoch': epoch, 'state_dict': discriminator.state_dict(), 'miou': miou } if miou > best_miou: best_miou = miou torch.save( snapshot, os.path.join(snapshot_dir, '{}_maxmiou.pth.tar'.format(prefix))) torch.save( snapshot_dis, os.path.join(snapshot_dir, '{}_dis_maxmiou.pth.tar'.format(prefix))) if eiou > best_eiou: best_eiou = eiou torch.save( snapshot, os.path.join(snapshot_dir, '{}_maxeiou.pth.tar'.format(prefix))) print( "[{}] Curr mIoU: {:0.4f} Curr eIoU: {:0.4f} Best mIoU: {:0.4f} Best eIoU: {:0.4f}" .format(epoch, miou, eiou, best_miou, best_eiou)) return best_miou, best_eiou
def snapshote(model, valoader, epoch, best_miou, best_eiou, snapshot_dir, prefix): miou, eiou = val_e(model, valoader) # eiou = val_sigmoid(model,valoader) # eiou = -2 snapshot = { 'epoch': epoch, 'state_dict': model.state_dict(), 'miou': miou, 'eiou': eiou } if miou > best_miou: best_miou = miou torch.save( snapshot, os.path.join(snapshot_dir, '{}_maxmiou.pth.tar'.format(prefix))) if eiou > best_eiou: best_eiou = eiou torch.save( snapshot, os.path.join(snapshot_dir, '{}_maxeiou.pth.tar'.format(prefix))) print( "[{}] Curr mIoU: {:0.4f} Curr eIoU: {:0.4f} Best mIoU: {:0.4f} Best eIoU: {:0.4f}" .format(epoch, miou, eiou, best_miou, best_eiou)) return best_miou, best_eiou