ColorNet(灰图涂色)

本文介绍了一种利用深度学习将灰度图像转换为彩色图像的方法。通过选用VGG-16模型作为基础,并采用复杂的损失函数进行训练,提高了模型的表现。文章详细描述了网络架构及训练过程。
部署运行你感兴趣的模型镜像

最近在阅读一些AI项目,写入markdown,持续更新,算是之后也能回想起做法

项目 https://github.com/calssion/Fun_AI

add color for grayscale image(为灰度图添加色彩)

sources from pavelgonchar(资料来源):https://github.com/pavelgonchar/colornet

tutorial(教程) http://tinyclouds.org/colorize/

The input to the model is the left-side grayscale image. The output is the middle image. The right image is the true color—which the model never gets to see. (输入是左边的灰度图,输出是中间的图像,右边的图像是真实的图像但模型不可见)


image

we all knew the grayscale image and the rgb image(我们都知道灰度图和rgb图),
now explain the YUV image(现在解释一下YUV图)。
https://en.wikipedia.org/wiki/YUV
YUV is a color encoding system typically used as part of a color image pipeline.(YUV是一种颜色编码系统,通常被用作彩色图像管道的一部分。)

First order of business was picking a pre-trained model to use(首先是选一个预训练模型来使用),
chose the VGG-16 model because it has a simple architecure yet still competitive(选择VGG-16模型因为它有完整的简单架构)。


image

Rather than reconstructing the entire color RGB image, I trained models to produce two color channels which I concatenate with the grayscale input channel to produce a YUV image.(比起重建一个完整的rgb图,我选择训练模型生成两个色道,从而与灰度图的输入色道连接在一起来生成一个YUV图像)。

image

Loss(计算损失)

The most obvious loss function is a Euclidean distance function between the network RGB output image and the true color RGB image. This works to some extent but I found models converged faster when I used a more complex loss function.(最突出的损失函数是用欧式距离计算网络生成图像与真实图像。这对于很多情况都可行,但我发现当我使用更复杂的损失函数时,模型更快地收敛。)

Blurring the network output and the true color image and doing Euclidean distance seems to give the gradient decent help. I ended up averaging the normal rgb distance and two blur distances with 3 and 5 pixel gaussian kernels.(欧式距离计算网络生成图像与真实图像,看似可以帮助梯度下降。我最终用3像素和5像素高斯核平均正常的rgb距离和两个色道距离。)

Also I only calculuate the distance in UV space.(当然我只计算YUV图的UV道)

Network Architecture(网络架构)

I use ReLUs as activation functions throughout except at the last output to UV channels—there I use a sigmoid to squash values between 0 and 1.(除了最后一层输出UV道,使用sigmoid产生0到1的值外,其他层我使用了ReLUs作为激活函数)

I use batch norm (BN) instead of bias terms behind every convolution(在每一次卷积后,我使用batch_norm代替偏置项)

Unlike in classification models there is no max pooling. I need the output to be at full 224 x 224 resolution(不同于分类模型,这里没有max pooling,我需要输出完整的224 x 224尺寸的结果)

The model forwards a grayscale image thru VGG16 and then using the highest layer infers some color information. Then it upscales the color guess and adds in information from the next highest layer, and so on working down to the bottom of the VGG16 until there is 224 x 224 x 3 tensor.(模型让一张灰度图通过VGG16结构,然后用更高的层得到颜色的信息。然后它更新颜色的预测并加入下一层的信息当中,最后运行到VGG16的最后一层直至其产生了244 x 244 x 3 的张量,也即结果)
image

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

### 如何在 GeoGebra 中给形填充颜色 #### 使用 IntegralBetween 命令填充复杂区域的颜色 对于带有曲线和直线混合边界的封闭区域,可以利用 `IntegralBetween` 函数来实现色彩填充。不过需要注意的是,在制作较为复杂的像如三原色时,可能需要定义多个函数以及执行多次积分操作[^1]。 ```plaintext f(x) = ... g(x) = ... h(x) = ... a = IntegralBetween(f, g, start_x, end_x) b = IntegralBetween(g, h, start_y, end_y) SetColor(a, "Red") # 设置积分区域 a 的颜色为红色 SetColor(b, "Blue") # 设置积分区域 b 的颜色为蓝色 ``` #### 利用曲面指令进行涂色 另一种方法是通过曲面指令来进行着色处理。例如,“曲线 (2cos(t), 2sin(t), t, 0, 2π)” 创建了一个以坐标系原点为中心、半径等于 2 的圆形路径;可以通过调整参数范围和其他属性来自由改变形状并应用不同的颜色方案[^4]。 ```geogebra c = Curve[2 cos(t), 2 sin(t), t, 0, 2 π] d = Surface[c(u), u, v, uMin=0, uMax=2 π, vMin=-1, vMax=1] SetColor(d, RGB(255, 0, 0)) # 将表面 d 设定为纯红 ``` #### 半圆工具的应用 当涉及到简单的几何对象比如半圆时,则可以直接运用内置的 “过两点画半圆” 工具完成绘与上色工作。此工具允许用户仅需指定两个端点就能迅速构建出相应的半圆结构,并支持进一步定制其外观特性,包括但不限于设置特定的颜色样式[^2]。 ```geogebra A = Point[(0, 0)] B = Point[(4, 0)] semicircleAB = Semicircle[A, B] SetColor(semicircleAB, Green) # 给半圆 AB 上绿色 ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值