CV之IG:基于CNN网络架构+ResNet网络进行DIY图像生成网络

举报
一个处女座的程序猿 发表于 2021/03/30 22:15:58 2021/03/30
【摘要】 CV之IG:基于CNN网络架构+ResNet网络进行DIY图像生成网络     目录 设计思路 实现代码       设计思路   实现代码 # 定义图像生成网络:image, training,两个参数 # Less border effects when padding a little before passing through .. ...

CV之IG:基于CNN网络架构+ResNet网络进行DIY图像生成网络

 

 

目录

设计思路

实现代码


 

 

 

设计思路

 

实现代码


  
  1. # 定义图像生成网络:image, training,两个参数
  2. # Less border effects when padding a little before passing through ..
  3. image = tf.pad(image, [[0, 0], [10, 10], [10, 10], [0, 0]], mode='REFLECT')
  4. with tf.variable_scope('conv1'):
  5. conv1 = relu(instance_norm(conv2d(image, 3, 32, 9, 1)))
  6. with tf.variable_scope('conv2'):
  7. conv2 = relu(instance_norm(conv2d(conv1, 32, 64, 3, 2)))
  8. with tf.variable_scope('conv3'):
  9. conv3 = relu(instance_norm(conv2d(conv2, 64, 128, 3, 2)))
  10. with tf.variable_scope('res1'):
  11. res1 = residual(conv3, 128, 3, 1)
  12. with tf.variable_scope('res2'):
  13. res2 = residual(res1, 128, 3, 1)
  14. with tf.variable_scope('res3'):
  15. res3 = residual(res2, 128, 3, 1)
  16. with tf.variable_scope('res4'):
  17. res4 = residual(res3, 128, 3, 1)
  18. with tf.variable_scope('res5'):
  19. res5 = residual(res4, 128, 3, 1)
  20. # print(res5.get_shape())
  21. with tf.variable_scope('deconv1'):
  22. # deconv1 = relu(instance_norm(conv2d_transpose(res5, 128, 64, 3, 2)))
  23. deconv1 = relu(instance_norm(resize_conv2d(res5, 128, 64, 3, 2, training)))
  24. with tf.variable_scope('deconv2'):
  25. # deconv2 = relu(instance_norm(conv2d_transpose(deconv1, 64, 32, 3, 2)))
  26. deconv2 = relu(instance_norm(resize_conv2d(deconv1, 64, 32, 3, 2, training)))
  27. with tf.variable_scope('deconv3'):
  28. # deconv_test = relu(instance_norm(conv2d(deconv2, 32, 32, 2, 1)))
  29. deconv3 = tf.nn.tanh(instance_norm(conv2d(deconv2, 32, 3, 9, 1)))
  30. y = (deconv3 + 1) * 127.5
  31. height = tf.shape(y)[1]
  32. width = tf.shape(y)[2]
  33. y = tf.slice(y, [0, 10, 10, 0], tf.stack([-1, height - 20, width - 20, -1]))
  34. return y

 

文章来源: yunyaniu.blog.csdn.net,作者:一个处女座的程序猿,版权归原作者所有,如需转载,请联系作者。

原文链接:yunyaniu.blog.csdn.net/article/details/82941106

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。