🍨 本文为:[🔗365天深度学习训练营] 中的学习记录博客
🍖 原作者:[K同学啊 | 接辅导、项目定制]
要求:
- 了解并学习Pix2Pix算法
- 画出本文代码中Pix2Pix的生成器网络结构
一、 基础配置
- 语言环境:Python3.8
- 编译器选择:Pycharm
- 深度学习环境:
-
- torch==1.12.1+cu113
- torchvision==0.13.1+cu113
二、 相关代码
1. 文件结构
- pix2pix
- data_facades
- test
- train
- val
- datasets.py
- models.py
- pix2pix.py
- data_facades
2. 代码细节
datasets.py
import glob
import random
import os
import numpy as np
from torch.utils.data import Dataset
from PIL import Image
import torchvision.transforms as transforms
class ImageDataset(Dataset):
def __init__(self, root, transforms_=None, mode="train"):
self.transform = transforms.Compose(transforms_)
self.files = sorted(glob.glob(os.path.join(root, mode) + "/*.*"))
if mode == "train":
self.files.extend(sorted(glob.glob(os.path.join(root, "test") + "/*.*")))
def __getitem__(self, index):
img = Image.open(self.files[index % len(self.files)])
w, h = img.size
img_A = img.crop((0, 0, w / 2, h))
img_B = img.crop((w / 2, 0, w, h))
if np.random.random() < 0.5:
img_A = Image.fromarray(np.array(img_A)[:, ::-1, :], "RGB")
img_B = Image.fromarray(np.array(img_B)[:, ::-1, :], "RGB")
img_A = self.transform(img_A)
img_B = self.transform(img_B)
return {"A": img_A, "B": img_B}
def __len__(self):
return len(self.files)
models.py
import torch.nn as nn
import torch.nn.functional as F
import torch
def weights_init_normal(m):
classname = m.__class__.__name__
if classname.find("Conv") != -1:
torch.nn.init.normal_(m.weight.data, 0.0, 0.02)
elif classname.find("BatchNorm2d") != -1:
torch.nn.init.normal_(m.weight.data, 1.0, 0.02)
torch.nn.init.constant_(m.bias.data, 0.0)
##############################
# U-NET
##############################
class UNetDown(nn.Module):
def __init__(self, in_size, out_size, normalize=True, dropout=0.0):
super(UNetDown, self).__init__()
layers = [nn.Conv2d(in_size, out_size, 4, 2, 1, bias=False)]
if normalize:
layers.append(nn.InstanceNorm2d(out_size))
layers.append(nn.LeakyReLU(0.2))
if dropout:
layers.append(nn.Dropout(dropout))
self.model = nn.Sequential(*layers)
def forward(self, x):
return self.model(x)
class UNetUp(nn.Module):
def __init__(self, in_size, out_size, dropout=0.0):
super(UNetUp, self).__init__()
layers = [
nn.ConvTranspose2d(in_size, out_size, 4, 2, 1, bias=False),
nn.InstanceNorm2d(out_size),
nn.ReLU(inplace=True),
]
if dropout:
layers.append(nn.Dropout(dropout))
self.model = nn.Sequential(*layers)
def forward(self, x, skip_input):
x = self.model(x)
x = torch.cat((x, skip_input), 1)
return x
class GeneratorUNet(nn.Module):
def __init__(self, in_channels=3, out_channels=3):
super(GeneratorUNet, self).__init__()
self.down1 = UNetDown(in_channels, 64, normalize=False)
self.down2 = UNetDown(64, 128)
self.down3 = UNetDown(128, 256)
self.down4 = UNetDown(256, 512, dropout=0.5)
self.down5 = UNetDown(512, 512, dropout=0.5)
self.down6 = UNetDown(512, 512, dropout=0.5)
self.down7 = UNetDown(512, 512, dropout=0.5)
self.down8 = UNetDown(512, 512, normalize=False, dropout=0.5)
self.up1 = UNetUp(512, 512, dropout=0.5)
self.up2 = UNetUp(1024, 512, dropout=0.5)
self.up3 = UNetUp(1024, 512, dropout=0.5)
self.up4 = UNetUp(1024, 512, dropout=0.5)
self.up5 = UNetUp(1024, 256)
self.up6 = UNetUp(512, 128)
self.up7 = UNetUp(256, 64)
self.final = nn.Sequential(
nn.Upsample(scale_factor=2),
nn.ZeroPad2d((1, 0, 1, 0)),
nn.Conv2d(128, out_channels, 4, padding=1),
nn.Tanh(),
)
def forward(self, x):
# U-Net generator with skip connections from encoder to decoder
d1 = self.down1(x)
d2 = self.down2(d1)
d3 = self.down3(d2)
d4 = self.down4(d3)
d5 = self.down5(d4)
d6 = self.down6(d5)
d7 = self.down7(d6)
d8 = self.down8(d7)
u1 = self.up1(d8, d7)
u2 = self.up2(u1, d6)
u3 = self.up3(u2, d5)
u4 = self.up4(u3, d4)
u5 = self.up5(u4, d3)
u6 = self.up6(u5, d2)
u7 = self.up7(u6, d1)
return self.final(u7)
##############################
# Discriminator
##############################
class Discriminator(nn.Module):
def __init__(self, in_channels=3):
super(Discriminator, self).__init__()
def discriminator_block(in_filters, out_filters, normalization=True):
"""Returns downsampling layers of each discriminator block"""
layers = [nn.Conv2d(in_filters, out_filters, 4, stride=2, padding=1)]
if normalization:
layers.append(nn.InstanceNorm2d(out_filters))
layers.append(nn.LeakyReLU(0.2, inplace=True))
return layers
self.model = nn.Sequential(
*discriminator_block(in_channels * 2, 64, normalization=False),
*discriminator_block(64, 128),
*discriminator_block(128, 256),
*discriminator_block(256, 512),
nn.ZeroPad2d((1, 0, 1, 0)),
nn.Conv2d(512, 1, 4, padding=1, bias=False)
)
def forward(self, img_A, img_B):
# Concatenate image and condition image by channels to produce input
img_input = torch.cat((img_A, img_B), 1)
return self.model(img_input)
pix2pix.py
import argparse
import time
import datetime
import sys
from torchvision.utils import save_image
from torch.utils.data import DataLoader
from torch.autograd import Variable
from models import *
from datasets import *
import torch
import warnings
warnings.filterwarnings('ignore')
parser = argparse.ArgumentParser()
parser.add_argument("--epoch", type=int, default=0, help="epoch to start training from")
parser.add_argument("--n_epochs", type=int, default=50, help="number of epochs of training")
parser.add_argument("--dataset_name", type=str, default="data_facades", help="name of the dataset")
parser.add_argument("--batch_size", type=int, default=1, help="size of the batches")
parser.add_argument("--lr", type=float, default=0.0002, help="adam: learning rate")
parser.add_argument("--b1", type=float, default=0.5, help="adam: decay of first order momentum of gradient")
parser.add_argument("--b2", type=float, default=0.999, help="adam: decay of first order momentum of gradient")
parser.add_argument("--decay_epoch", type=int, default=100, help="epoch from which to start lr decay")
parser.add_argument("--n_cpu", type=int, default=2, help="number of cpu threads to use during batch generation")
parser.add_argument("--img_height", type=int, default=256, help="size of image height")
parser.add_argument("--img_width", type=int, default=256, help="size of image width")
parser.add_argument("--channels", type=int, default=3, help="number of image channels")
parser.add_argument(
"--sample_interval", type=int, default=500, help="interval between sampling of images from generators"
)
parser.add_argument("--checkpoint_interval", type=int, default=-1, help="interval between model checkpoints")
opt = parser.parse_args()
print(opt)
os.makedirs("images/%s" % opt.dataset_name, exist_ok=True)
os.makedirs("saved_models/%s" % opt.dataset_name, exist_ok=True)
cuda = True if torch.cuda.is_available() else False
# Loss functions
criterion_GAN = torch.nn.MSELoss()
criterion_pixelwise = torch.nn.L1Loss()
# Loss weight of L1 pixel-wise loss between translated image and real image
lambda_pixel = 100
# Calculate output of image discriminator (PatchGAN)
patch = (1, opt.img_height // 2 ** 4, opt.img_width // 2 ** 4)
# Initialize generator and discriminator
generator = GeneratorUNet()
discriminator = Discriminator()
if cuda:
generator = generator.cuda()
discriminator = discriminator.cuda()
criterion_GAN.cuda()
criterion_pixelwise.cuda()
if opt.epoch != 0:
# Load pretrained models
generator.load_state_dict(torch.load("saved_models/%s/generator_%d.pth" % (opt.dataset_name, opt.epoch)))
discriminator.load_state_dict(torch.load("saved_models/%s/discriminator_%d.pth" % (opt.dataset_name, opt.epoch)))
else:
# Initialize weights
generator.apply(weights_init_normal)
discriminator.apply(weights_init_normal)
# Optimizers
optimizer_G = torch.optim.Adam(generator.parameters(), lr=opt.lr, betas=(opt.b1, opt.b2))
optimizer_D = torch.optim.Adam(discriminator.parameters(), lr=opt.lr, betas=(opt.b1, opt.b2))
# Configure dataloaders
transforms_ = [
transforms.Resize((opt.img_height, opt.img_width), Image.BICUBIC),
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
]
dataloader = DataLoader(
ImageDataset("./%s" % opt.dataset_name, transforms_=transforms_),
batch_size=opt.batch_size,
shuffle=True,
num_workers=opt.n_cpu,
)
val_dataloader = DataLoader(
ImageDataset("./%s" % opt.dataset_name, transforms_=transforms_, mode="val"),
batch_size=10,
shuffle=True,
num_workers=1,
)
# Tensor type
Tensor = torch.cuda.FloatTensor if cuda else torch.FloatTensor
def sample_images(batches_done):
"""Saves a generated sample from the validation set"""
imgs = next(iter(val_dataloader))
real_A = Variable(imgs["B"].type(Tensor))
real_B = Variable(imgs["A"].type(Tensor))
fake_B = generator(real_A)
img_sample = torch.cat((real_A.data, fake_B.data, real_B.data), -2)
save_image(img_sample, "images/%s/%s.png" % (opt.dataset_name, batches_done), nrow=5, normalize=True)
# ----------
# Training
# ----------
if __name__ == '__main__':
prev_time = time.time()
for epoch in range(opt.epoch, opt.n_epochs):
for i, batch in enumerate(dataloader):
# Model inputs
real_A = Variable(batch["B"].type(Tensor))
real_B = Variable(batch["A"].type(Tensor))
# Adversarial ground truths
valid = Variable(Tensor(np.ones((real_A.size(0), *patch))), requires_grad=False)
fake = Variable(Tensor(np.zeros((real_A.size(0), *patch))), requires_grad=False)
# ------------------
# Train Generators
# ------------------
optimizer_G.zero_grad()
# GAN loss
fake_B = generator(real_A)
pred_fake = discriminator(fake_B, real_A)
loss_GAN = criterion_GAN(pred_fake, valid)
# Pixel-wise loss
loss_pixel = criterion_pixelwise(fake_B, real_B)
# Total loss
loss_G = loss_GAN + lambda_pixel * loss_pixel
loss_G.backward()
optimizer_G.step()
# ---------------------
# Train Discriminator
# ---------------------
optimizer_D.zero_grad()
# Real loss
pred_real = discriminator(real_B, real_A)
loss_real = criterion_GAN(pred_real, valid)
# Fake loss
pred_fake = discriminator(fake_B.detach(), real_A)
loss_fake = criterion_GAN(pred_fake, fake)
# Total loss
loss_D = 0.5 * (loss_real + loss_fake)
loss_D.backward()
optimizer_D.step()
# --------------
# Log Progress
# --------------
# Determine approximate time left
batches_done = epoch * len(dataloader) + i
batches_left = opt.n_epochs * len(dataloader) - batches_done
time_left = datetime.timedelta(seconds=batches_left * (time.time() - prev_time))
prev_time = time.time()
# Print log
sys.stdout.write(
"\r[Epoch %d/%d] [Batch %d/%d] [D loss: %f] [G loss: %f, pixel: %f, adv: %f] ETA: %s"
% (
epoch,
opt.n_epochs,
i,
len(dataloader),
loss_D.item(),
loss_G.item(),
loss_pixel.item(),
loss_GAN.item(),
time_left,
)
)
# If at sample interval save image
if batches_done % opt.sample_interval == 0:
sample_images(batches_done)
if opt.checkpoint_interval != -1 and epoch % opt.checkpoint_interval == 0:
# Save model checkpoints
torch.save(generator.state_dict(), "saved_models/%s/generator_%d.pth" % (opt.dataset_name, epoch))
torch.save(discriminator.state_dict(), "saved_models/%s/discriminator_%d.pth" % (opt.dataset_name, epoch))
输出结果为:
C:\Users\nemop\.conda\envs\P113\python.exe C:\NNStudy\Study\Pix2Pix\pix2pix.py
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 0/50] [Batch 0/506] [D loss: 2.120547] [G loss: 46.905365, pixel: 0.439291, adv: 2.976255] ETA: 2 days, 1:52:14.432769Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 0/50] [Batch 500/506] [D loss: 0.178138] [G loss: 29.325426, pixel: 0.281019, adv: 1.223516] ETA: 0:23:27.389641Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 0/50] [Batch 505/506] [D loss: 0.144148] [G loss: 44.965244, pixel: 0.445120, adv: 0.453239] ETA: 0:21:45.184193Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 1/50] [Batch 494/506] [D loss: 0.058155] [G loss: 29.411367, pixel: 0.287625, adv: 0.648884] ETA: 0:18:30.059881Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 1/50] [Batch 505/506] [D loss: 0.019859] [G loss: 34.564346, pixel: 0.335710, adv: 0.993333] ETA: 0:19:49.136604Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 2/50] [Batch 488/506] [D loss: 0.019303] [G loss: 32.974598, pixel: 0.318522, adv: 1.122382] ETA: 0:21:46.913424Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 2/50] [Batch 505/506] [D loss: 0.032963] [G loss: 60.382744, pixel: 0.591032, adv: 1.279571] ETA: 0:19:27.992943Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 3/50] [Batch 482/506] [D loss: 0.058160] [G loss: 38.912128, pixel: 0.377501, adv: 1.162022] ETA: 0:18:53.856702Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 3/50] [Batch 505/506] [D loss: 0.024793] [G loss: 39.273933, pixel: 0.382994, adv: 0.974544] ETA: 0:19:56.469846Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 4/50] [Batch 476/506] [D loss: 0.068410] [G loss: 32.155556, pixel: 0.306792, adv: 1.476340] ETA: 0:20:15.607452Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 4/50] [Batch 505/506] [D loss: 0.017099] [G loss: 39.535625, pixel: 0.387563, adv: 0.779331] ETA: 0:19:00.660807Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 5/50] [Batch 470/506] [D loss: 0.020615] [G loss: 45.147377, pixel: 0.438832, adv: 1.264170] ETA: 0:20:10.960674Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 5/50] [Batch 505/506] [D loss: 0.046003] [G loss: 22.988733, pixel: 0.223286, adv: 0.660156] ETA: 0:19:02.641492Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 6/50] [Batch 464/506] [D loss: 0.012475] [G loss: 33.149433, pixel: 0.323028, adv: 0.846636] ETA: 0:17:38.616304Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 6/50] [Batch 505/506] [D loss: 0.068318] [G loss: 43.630173, pixel: 0.430630, adv: 0.567191] ETA: 0:16:49.759197Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 7/50] [Batch 458/506] [D loss: 0.014546] [G loss: 33.989143, pixel: 0.330266, adv: 0.962536] ETA: 0:17:26.452975Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 7/50] [Batch 505/506] [D loss: 0.043874] [G loss: 34.019508, pixel: 0.333941, adv: 0.625449] ETA: 0:18:10.340743Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 8/50] [Batch 452/506] [D loss: 0.105170] [G loss: 32.545296, pixel: 0.314449, adv: 1.100438] ETA: 0:19:11.048279Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 8/50] [Batch 505/506] [D loss: 0.011343] [G loss: 28.931974, pixel: 0.280629, adv: 0.869117] ETA: 0:15:15.186035Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 9/50] [Batch 446/506] [D loss: 0.033980] [G loss: 49.197403, pixel: 0.477602, adv: 1.437211] ETA: 0:16:25.291743Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 9/50] [Batch 505/506] [D loss: 0.109652] [G loss: 27.869932, pixel: 0.274658, adv: 0.404089] ETA: 0:15:46.128191Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 10/50] [Batch 440/506] [D loss: 0.087159] [G loss: 30.811535, pixel: 0.303785, adv: 0.433008] ETA: 0:17:33.459263Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 10/50] [Batch 505/506] [D loss: 0.031147] [G loss: 38.411480, pixel: 0.375912, adv: 0.820262] ETA: 0:14:21.026365Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 11/50] [Batch 434/506] [D loss: 0.007330] [G loss: 35.891857, pixel: 0.349066, adv: 0.985206] ETA: 0:17:00.203018Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 11/50] [Batch 505/506] [D loss: 0.098203] [G loss: 37.015667, pixel: 0.365276, adv: 0.488087] ETA: 0:15:37.925753Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 12/50] [Batch 428/506] [D loss: 0.005904] [G loss: 23.991585, pixel: 0.229150, adv: 1.076538] ETA: 0:15:41.832352Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 12/50] [Batch 505/506] [D loss: 0.012911] [G loss: 40.356361, pixel: 0.395494, adv: 0.807002] ETA: 0:12:49.569338Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 13/50] [Batch 422/506] [D loss: 0.005118] [G loss: 39.827080, pixel: 0.388467, adv: 0.980332] ETA: 0:17:49.804859Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 13/50] [Batch 505/506] [D loss: 0.015462] [G loss: 38.131855, pixel: 0.372946, adv: 0.837252] ETA: 0:17:08.521379Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 14/50] [Batch 416/506] [D loss: 0.007606] [G loss: 23.220619, pixel: 0.222119, adv: 1.008741] ETA: 0:14:34.513340Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 14/50] [Batch 505/506] [D loss: 0.007736] [G loss: 20.776545, pixel: 0.197760, adv: 1.000570] ETA: 0:15:06.299166Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 15/50] [Batch 410/506] [D loss: 0.015369] [G loss: 35.453518, pixel: 0.345131, adv: 0.940383] ETA: 0:14:44.620094Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 15/50] [Batch 505/506] [D loss: 0.010403] [G loss: 37.952179, pixel: 0.368552, adv: 1.097019] ETA: 0:13:31.045790Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 16/50] [Batch 404/506] [D loss: 0.030206] [G loss: 45.571011, pixel: 0.442926, adv: 1.278415] ETA: 0:14:52.738724Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 16/50] [Batch 505/506] [D loss: 0.007322] [G loss: 36.920830, pixel: 0.359818, adv: 0.939081] ETA: 0:12:36.365281Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 17/50] [Batch 398/506] [D loss: 0.003598] [G loss: 26.794537, pixel: 0.258169, adv: 0.977672] ETA: 0:13:09.913654Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 17/50] [Batch 505/506] [D loss: 0.006808] [G loss: 47.424892, pixel: 0.463348, adv: 1.090045] ETA: 0:13:58.948172Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 18/50] [Batch 392/506] [D loss: 0.008659] [G loss: 29.037411, pixel: 0.281504, adv: 0.887019] ETA: 0:12:55.831509Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 18/50] [Batch 505/506] [D loss: 0.002096] [G loss: 44.415039, pixel: 0.433716, adv: 1.043489] ETA: 0:12:21.708688Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 19/50] [Batch 386/506] [D loss: 0.004421] [G loss: 29.186646, pixel: 0.281626, adv: 1.024012] ETA: 0:10:29.330134Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 19/50] [Batch 505/506] [D loss: 0.008713] [G loss: 36.611286, pixel: 0.355981, adv: 1.013227] ETA: 0:12:10.513671Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 20/50] [Batch 380/506] [D loss: 0.008213] [G loss: 29.808434, pixel: 0.287584, adv: 1.050004] ETA: 0:12:46.601372Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 20/50] [Batch 505/506] [D loss: 0.007512] [G loss: 35.687508, pixel: 0.346671, adv: 1.020363] ETA: 0:11:58.375605Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 21/50] [Batch 374/506] [D loss: 0.007330] [G loss: 29.338795, pixel: 0.282488, adv: 1.089955] ETA: 0:11:22.657886Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 21/50] [Batch 505/506] [D loss: 0.005063] [G loss: 36.397511, pixel: 0.354302, adv: 0.967319] ETA: 0:12:32.686236Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 22/50] [Batch 368/506] [D loss: 0.003426] [G loss: 37.780121, pixel: 0.367079, adv: 1.072234] ETA: 0:12:07.161884Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 22/50] [Batch 505/506] [D loss: 0.003645] [G loss: 37.703381, pixel: 0.367614, adv: 0.941956] ETA: 0:10:48.209264Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 23/50] [Batch 362/506] [D loss: 0.040089] [G loss: 26.172892, pixel: 0.252225, adv: 0.950376] ETA: 0:11:37.577882Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 23/50] [Batch 505/506] [D loss: 0.004438] [G loss: 28.593239, pixel: 0.275601, adv: 1.033159] ETA: 0:10:32.343456Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 24/50] [Batch 356/506] [D loss: 0.001854] [G loss: 31.993052, pixel: 0.309705, adv: 1.022520] ETA: 0:09:48.711548Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 24/50] [Batch 505/506] [D loss: 0.003472] [G loss: 28.758240, pixel: 0.277524, adv: 1.005792] ETA: 0:10:51.829161Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 25/50] [Batch 350/506] [D loss: 0.002718] [G loss: 25.189060, pixel: 0.242021, adv: 0.986952] ETA: 0:10:28.905559Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 25/50] [Batch 505/506] [D loss: 0.002969] [G loss: 36.854740, pixel: 0.358645, adv: 0.990274] ETA: 0:10:06.852725Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 26/50] [Batch 344/506] [D loss: 0.004154] [G loss: 27.227598, pixel: 0.262473, adv: 0.980309] ETA: 0:10:28.170824Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 26/50] [Batch 505/506] [D loss: 0.002406] [G loss: 25.096933, pixel: 0.241094, adv: 0.987580] ETA: 0:09:30.366788Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 27/50] [Batch 338/506] [D loss: 0.006147] [G loss: 25.924360, pixel: 0.250126, adv: 0.911718] ETA: 0:09:50.154552Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 27/50] [Batch 505/506] [D loss: 0.002861] [G loss: 36.782192, pixel: 0.357660, adv: 1.016201] ETA: 0:09:28.514253Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 28/50] [Batch 332/506] [D loss: 0.018754] [G loss: 19.939678, pixel: 0.190832, adv: 0.856480] ETA: 0:08:28.994865Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 28/50] [Batch 505/506] [D loss: 0.007137] [G loss: 41.722542, pixel: 0.406709, adv: 1.051621] ETA: 0:09:46.079391Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 29/50] [Batch 326/506] [D loss: 0.003144] [G loss: 25.841633, pixel: 0.247965, adv: 1.045161] ETA: 0:08:26.613255Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 29/50] [Batch 505/506] [D loss: 0.020236] [G loss: 25.448471, pixel: 0.245079, adv: 0.940563] ETA: 0:08:13.788889Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 30/50] [Batch 320/506] [D loss: 0.003752] [G loss: 23.666348, pixel: 0.226330, adv: 1.033345] ETA: 0:07:48.139219Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 30/50] [Batch 505/506] [D loss: 0.002398] [G loss: 29.302134, pixel: 0.282130, adv: 1.089153] ETA: 0:08:10.026863Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 31/50] [Batch 314/506] [D loss: 0.001211] [G loss: 25.154154, pixel: 0.241748, adv: 0.979381] ETA: 0:08:12.784452Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 31/50] [Batch 505/506] [D loss: 0.000945] [G loss: 32.078442, pixel: 0.310825, adv: 0.995949] ETA: 0:08:04.210115Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 32/50] [Batch 308/506] [D loss: 0.002173] [G loss: 27.432039, pixel: 0.263771, adv: 1.054988] ETA: 0:07:25.970726Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 32/50] [Batch 505/506] [D loss: 0.002896] [G loss: 25.211002, pixel: 0.241745, adv: 1.036515] ETA: 0:08:23.751802Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 33/50] [Batch 302/506] [D loss: 0.001799] [G loss: 19.686071, pixel: 0.186818, adv: 1.004259] ETA: 0:07:07.021265Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 33/50] [Batch 505/506] [D loss: 0.002455] [G loss: 25.911329, pixel: 0.248348, adv: 1.076557] ETA: 0:07:02.146672Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 34/50] [Batch 296/506] [D loss: 0.002308] [G loss: 23.641624, pixel: 0.226509, adv: 0.990705] ETA: 0:06:31.028023Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 34/50] [Batch 505/506] [D loss: 0.002152] [G loss: 24.272091, pixel: 0.232874, adv: 0.984653] ETA: 0:06:05.284515Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 35/50] [Batch 290/506] [D loss: 0.001247] [G loss: 21.595200, pixel: 0.205871, adv: 1.008100] ETA: 0:05:48.232102Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 35/50] [Batch 505/506] [D loss: 0.019104] [G loss: 24.502350, pixel: 0.233517, adv: 1.150635] ETA: 0:06:40.481257Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 36/50] [Batch 284/506] [D loss: 0.011365] [G loss: 30.808340, pixel: 0.299603, adv: 0.848016] ETA: 0:05:46.416569Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 36/50] [Batch 505/506] [D loss: 0.003670] [G loss: 25.197220, pixel: 0.241211, adv: 1.076138] ETA: 0:05:33.357328Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 37/50] [Batch 278/506] [D loss: 0.006345] [G loss: 22.263044, pixel: 0.212978, adv: 0.965199] ETA: 0:06:00.042787Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 37/50] [Batch 505/506] [D loss: 0.000763] [G loss: 24.089008, pixel: 0.230851, adv: 1.003909] ETA: 0:04:44.011625Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 38/50] [Batch 272/506] [D loss: 0.003851] [G loss: 22.189091, pixel: 0.213258, adv: 0.863312] ETA: 0:04:25.276146Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 38/50] [Batch 505/506] [D loss: 0.003049] [G loss: 30.102287, pixel: 0.290727, adv: 1.029616] ETA: 0:04:39.111591Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 39/50] [Batch 266/506] [D loss: 0.002462] [G loss: 22.286646, pixel: 0.213051, adv: 0.981535] ETA: 0:05:33.599067Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 39/50] [Batch 505/506] [D loss: 0.000776] [G loss: 25.155338, pixel: 0.241427, adv: 1.012646] ETA: 0:03:58.492897Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 40/50] [Batch 260/506] [D loss: 0.022566] [G loss: 28.759075, pixel: 0.278023, adv: 0.956751] ETA: 0:03:23.925705Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 40/50] [Batch 505/506] [D loss: 0.116388] [G loss: 21.571711, pixel: 0.200463, adv: 1.525447] ETA: 0:03:39.560282Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 41/50] [Batch 254/506] [D loss: 0.002298] [G loss: 26.076492, pixel: 0.250504, adv: 1.026126] ETA: 0:03:47.567720Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 41/50] [Batch 505/506] [D loss: 0.002343] [G loss: 24.009888, pixel: 0.229965, adv: 1.013357] ETA: 0:03:00.066078Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 42/50] [Batch 248/506] [D loss: 0.000630] [G loss: 21.811567, pixel: 0.208105, adv: 1.001038] ETA: 0:02:50.806408Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 42/50] [Batch 505/506] [D loss: 0.001527] [G loss: 26.589022, pixel: 0.256072, adv: 0.981805] ETA: 0:02:43.424869Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 43/50] [Batch 242/506] [D loss: 0.001914] [G loss: 27.548643, pixel: 0.266138, adv: 0.934835] ETA: 0:02:50.773244Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 43/50] [Batch 505/506] [D loss: 0.000972] [G loss: 22.799290, pixel: 0.217626, adv: 1.036651] ETA: 0:02:19.564437Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 44/50] [Batch 236/506] [D loss: 0.001705] [G loss: 31.411657, pixel: 0.304165, adv: 0.995185] ETA: 0:02:09.138470Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 44/50] [Batch 505/506] [D loss: 0.006793] [G loss: 25.012074, pixel: 0.240233, adv: 0.988776] ETA: 0:02:00.164304Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 45/50] [Batch 230/506] [D loss: 0.001323] [G loss: 24.693291, pixel: 0.237133, adv: 0.979945] ETA: 0:01:53.185906Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 45/50] [Batch 505/506] [D loss: 0.001237] [G loss: 31.724941, pixel: 0.307451, adv: 0.979858] ETA: 0:01:44.043370Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 46/50] [Batch 224/506] [D loss: 0.000983] [G loss: 26.760288, pixel: 0.257485, adv: 1.011809] ETA: 0:01:33.053341Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 46/50] [Batch 505/506] [D loss: 0.001785] [G loss: 16.132702, pixel: 0.151278, adv: 1.004861] ETA: 0:01:10.738114Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 47/50] [Batch 218/506] [D loss: 0.008509] [G loss: 29.800434, pixel: 0.286709, adv: 1.129509] ETA: 0:01:09.161558Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 47/50] [Batch 505/506] [D loss: 0.005529] [G loss: 22.623722, pixel: 0.216991, adv: 0.924638] ETA: 0:00:51.798611Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 48/50] [Batch 212/506] [D loss: 0.000450] [G loss: 21.556780, pixel: 0.205656, adv: 0.991187] ETA: 0:00:36.760712Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 48/50] [Batch 505/506] [D loss: 0.001802] [G loss: 25.394165, pixel: 0.243527, adv: 1.041436] ETA: 0:00:25.297877Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 49/50] [Batch 206/506] [D loss: 0.001160] [G loss: 24.300886, pixel: 0.232767, adv: 1.024143] ETA: 0:00:14.331865Namespace(b1=0.5, b2=0.999, batch_size=1, channels=3, checkpoint_interval=-1, dataset_name='data_facades', decay_epoch=100, epoch=0, img_height=256, img_width=256, lr=0.0002, n_cpu=2, n_epochs=50, sample_interval=500)
[Epoch 49/50] [Batch 505/506] [D loss: 0.005092] [G loss: 21.434053, pixel: 0.204980, adv: 0.936065] ETA: 0:00:00.044938
Process finished with exit code 0
3. 总结
Pix2Pix是图像翻译必读的文章之一,它的核心技术有三点:基于CGAN的损失函数,基于U-Net的生成器和基于PatchGAN的判别器。Pix2Pix 能够在诸多图像翻译任务上取得令人惊艳的效果,但因为它的输入是图像对,因此它得到的模型还是有偏的。这里的有偏指的是模型能够在与数据集近似的 x 的情况下得到令人满意的生成内容,但是如果输入 x 与训练集的偏差过大,Pix2Pix 得到的结果便不那么理想了。
三、理论基础
1. 图像翻译
图像翻译指的是将图像从源域转换到目标域的过程,同时保持图像内容的一致性。具体解释如下:
图像内容(Content):这是图像的固有属性,指的是图像展示的对象、场景或任何其他可视化信息。图像内容是区分不同图像的主要依据。
图像域(Domain):在图像翻译的背景下,一个域可以被认为是一组具有共同特征的图像。例如,所有带有蓝色天空的照片可以属于同一个域。在图像翻译中,通常涉及至少两个域:源域和目标域。域内的图像可以认为其内容被赋予了某些相同的风格、纹理或其他视觉特性。
图像翻译(Image-to-Image Translation, I2I):这是一个过程,目的是将图像从一个域(源域)转换到另一个域(目标域),同时尽可能保留原始图像的内容。这涉及到一系列复杂的算法和模型,如生成对抗网络(GANs),它们能够捕捉并学习不同域之间的映射关系。这个过程在计算机视觉和图像处理领域有着广泛的应用,包括图像风格转换、草图着色、照片卡通化等。
2. U-Net
U-Net是一种专为图像分割任务设计的深度学习网络结构,具有以下特点:
编码器-解码器(Encoder-Decoder)结构:U-Net由一个收缩路径(编码器)和一个对称的扩展路径(解码器)组成。编码器部分主要负责通过卷积层提取特征,而解码器部分则用于上采样特征图,逐步恢复到原始图像的尺寸。
跳跃连接(Skip Connections):在编码和解码阶段之间存在跳跃连接,即从编码器到解码器的深层特征图会与解码器相应层次的输出进行拼接。这种设计可以帮助保持图像的细节信息,并有助于更好地进行精确的分割。
多层次特征融合:U-Net结构允许在不同层级的特征之间进行融合,这样可以让网络同时学习到浅层次的细节特征和深层次的语义特征,从而增强模型对不同尺度结构的识别能力。
3. Pix2Pix解析
Pix2Pix是一种基于条件生成对抗网络(cGAN)的图像翻译模型。它能够将输入的图像转换为对应的输出图像,通常用于解决图像到图像的转换问题。
原理结构:
编码器-解码器结构(U-Net):Pix2Pix的生成器G采用的是U-Net结构,这种结构通过跳跃连接(skip connections)使得网络能够更好地学习输入图像和输出图像之间的对应关系,保留图像的细节信息。
条件判别器(PatchGAN):判别器D使用的是PatchGAN结构,它的作用是在给定输入图像的条件下,判断输出图像是真实图像还是生成图像。PatchGAN不是对整个图像进行判别,而是对图像的局部区域(patches)进行判别,这样可以提高判别的效率和准确性。
条件对抗性网络(cGAN):Pix2Pix是基于cGAN的扩展,它在传统的GAN基础上增加了条件变量,使得生成器在生成图像时能够参考额外的信息,如输入图像或者其他条件信息。
优势:
端到端训练:Pix2Pix可以实现端到端的训练,不需要复杂的图像预处理或后处理步骤。
通用性强:虽然Pix2Pix是为特定的图像转换任务设计的,但由于其基于cGAN的结构,它具有很好的通用性,可以应用于多种图像到图像的转换任务。
高质量的输出:Pix2Pix能够生成高分辨率、高质量的图像,这得益于其精细的网络结构和训练过程。
劣势:
计算资源要求高:由于Pix2Pix使用了深度学习模型,尤其是GAN,它的训练过程需要大量的计算资源和时间。
模型调优难度大:GAN类模型通常较难训练,需要精心设计的网络架构和合适的超参数设置。
可能的模式崩溃(Mode Collapse):在某些情况下,GAN可能会生成非常相似的输出,而忽略了输入数据中的多样性。
综上所述,Pix2Pix以其强大的图像转换能力和较高的通用性在图像处理领域得到了广泛的应用,但同时也面临着计算资源要求高和模型调优难度大等挑战。