Open 12ycli opened 4 years ago
I wonder too
I wonder too
From what the code show in edgeconnect. Model 3 only backpropagates for inpaint model, but use the output of edge_model as edge input. Model 4 backpropagates for edge model and inpaint model.
# inpaint with edge model
elif model == 3:
# train
if True or np.random.binomial(1, 0.5) > 0:
outputs = self.edge_model(images_gray, edges, masks)
outputs = outputs * masks + edges * (1 - masks)
else:
outputs = edges
outputs, gen_loss, dis_loss, logs = self.inpaint_model.process(images, outputs.detach(), masks)
outputs_merged = (outputs * masks) + (images * (1 - masks))
# metrics
psnr = self.psnr(self.postprocess(images), self.postprocess(outputs_merged))
mae = (torch.sum(torch.abs(images - outputs_merged)) / torch.sum(images)).float()
logs.append(('psnr', psnr.item()))
logs.append(('mae', mae.item()))
# backward
self.inpaint_model.backward(gen_loss, dis_loss)
iteration = self.inpaint_model.iteration
# joint model
else:
# train
e_outputs, e_gen_loss, e_dis_loss, e_logs = self.edge_model.process(images_gray, edges, masks)
e_outputs = e_outputs * masks + edges * (1 - masks)
i_outputs, i_gen_loss, i_dis_loss, i_logs = self.inpaint_model.process(images, e_outputs, masks)
outputs_merged = (i_outputs * masks) + (images * (1 - masks))
# metrics
psnr = self.psnr(self.postprocess(images), self.postprocess(outputs_merged))
mae = (torch.sum(torch.abs(images - outputs_merged)) / torch.sum(images)).float()
precision, recall = self.edgeacc(edges * masks, e_outputs * masks)
e_logs.append(('pre', precision.item()))
e_logs.append(('rec', recall.item()))
i_logs.append(('psnr', psnr.item()))
i_logs.append(('mae', mae.item()))
logs = e_logs + i_logs
# backward
self.inpaint_model.backward(i_gen_loss, i_dis_loss)
self.edge_model.backward(e_gen_loss, e_dis_loss)
Thx 搜马驰
Why do I have problems in the picture when I train model 4
您好,邮件已收到,我会及时处理。 郭春雨
Why do I have problems in the picture when I train model 4
Excuse me,have you solved the problem?
In config.yaml file, I see the MODEL option can be set to 3 or 4. While simple explaination is given below, I still don't understand the difference between
edge-inpaint model
andjoint model
.MODEL 1: edge model, 2: inpaint model, 3: edge-inpaint model, 4: joint model