ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

GFPGAN源码分析—第七篇

2021-12-06 23:00:08  阅读:206  来源: 互联网

标签:style code conditions self 第七篇 源码 GFPGAN path feat


2021SC@SDUSC

源码:archs\gfpganv1_clean_arch.py

本篇主要分析gfpganv1_clean_arch.py下的

class GFPGANv1Clean(nn.Module)类forward( ) 方法

目录

forward( )

(1)设置Style-GAN 编码器

(2)style code

(3)解码

(4)两个参数都为none,在此处并未用到

(5)解码器decoder


forward( )

参数:

            (self,
            x,
            return_latents=False,
            save_feat_path=None,
            load_feat_path=None,
            return_rgb=True,
            randomize_noise=True)

(1)设置Style-GAN 编码器

feat = F.leaky_relu_(self.conv_body_first(x), negative_slope=0.2)
for i in range(self.log_size - 2):
    feat = self.conv_body_down[i](feat)
    unet_skips.insert(0, feat)
feat = F.leaky_relu_(self.final_conv(feat), negative_slope=0.2)

(2)style code

style_code = self.final_linear(feat.view(feat.size(0), -1))
if self.different_w:
    style_code = style_code.view(style_code.size(0), -1, self.num_style_feat)

(3)解码

for i in range(self.log_size - 2):
    # add unet skip
    feat = feat + unet_skips[i]
    # ResUpLayer
    feat = self.conv_body_up[i](feat)
    # generate scale and shift for SFT layer
    scale = self.condition_scale[i](feat)
    conditions.append(scale.clone())
    shift = self.condition_shift[i](feat)
    conditions.append(shift.clone())
    # generate rgb images
    if return_rgb:
        out_rgbs.append(self.toRGB[i](feat))

(4)两个参数都为none,在此处并未用到

if save_feat_path is not None:
    torch.save(conditions, save_feat_path)
if load_feat_path is not None:
    conditions = torch.load(load_feat_path)
    conditions = [v.cuda() for v in conditions]

(5)解码器decoder

image, _ = self.stylegan_decoder([style_code],
                                 conditions,
                                 return_latents=return_latents,
                                 input_is_latent=self.input_is_latent,
                                 randomize_noise=randomize_noise)

标签:style,code,conditions,self,第七篇,源码,GFPGAN,path,feat
来源: https://blog.csdn.net/Vaifer233/article/details/121758206

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有