介绍 (Introduction)

When I see a historical black and white photo, I always wonder what was the real color, what did the photographer see when taking the photo.

当我看到一张历史性的黑白照片时,我总是想知道真正的色彩是什么,摄影师在拍摄照片时看到了什么。

It is not easy to discover the exact color of the B&W photos, but it is possible to colorize the photo based on experience and imagination. It can be done by investigating the possible colors of the objects in the photos, for example, the color of cloths, building, trees, cars, etc., and colorized them manually using some software such as Photoshop.

发现黑白照片的确切颜色并不容易,但是可以根据经验和想象为照片着色。 可以通过研究照片中对象的可能颜色(例如,衣服,建筑物,树木,汽车等的颜色)并使用某些软件(例如Photoshop)手动为它们上色来完成此操作。

The other approach is to train the computer to understand the colors of different objects by providing a large of amount color photos, then ask the computer to colorize by identifying plausible color for the detected objection. Thanks to the development of deep learning, it can be done by using Generative Adversarial Network (GAN).

另一种方法是通过提供大量彩色照片来训练计算机以了解不同对象的颜色,然后通过识别检测到的异物的合理颜色来要求计算机着色。 由于深度学习的发展,可以使用生成对抗网络(GAN)来完成。

生成对抗网络(GAN) (Generative Adversarial Network (GAN))

The idea of Generative Adversarial Networks is quite straightforward, it contains two neural networks, generator, and discriminator. The generator’s job is to predict the color based on the black and white photo and then generate colorized photos. The discriminator’s job is then to judge if the generated photo is real enough compared to the real photo.

生成对抗网络的思想非常简单,它包含两个神经网络,即生成器和鉴别器。 生成器的工作是根据黑白照片预测颜色,然后生成彩色照片。 鉴别者的工作是判断所生成的照片与真实照片相比是否足够真实。

If the discriminator can easily tell the photo is generated, which means the generator is not good enough, the generator needs more training. When the generator is improving and the discriminator cannot tell the difference anymore, the discriminator will be trained more in order to tell the difference.

如果辨别器可以轻松辨别出照片已生成,这意味着生成器不够好,则生成器需要更多的培训。 当生成器正在改进并且区分器无法再区分差异时,将对区分器进行更多的训练以区分差异。

In this work, I took Jason Antic’s DeOldify as reference (https://github.com/jantic/DeOldify) and trained a GAN using fastai.

在这项工作中,我以Jason Antic的DeOldify作为参考( https://github.com/jantic/DeOldify ),并使用fastai训练了GAN。

数据集 (Dataset)

I used ImageNet as my training dataset. However, due to the computation limit (12 hours runtime limit on Colab), it was not easy to use all the images, so I ended up using only 5000 images from it.

我使用ImageNet作为训练数据集。 但是,由于计算限制(Colab的运行时间限制为12小时),要使用所有图像并不容易,所以我最终只使用了其中的5000张图像。

Part of the training dataset
训练数据集的一部分

制作黑白照片 (Make black and white photos)

First I need to make the color image black and white for training. I also added a little bit of noise to give the images some kind of old photo feeling.

首先,我需要对彩色图像进行黑白训练。 我还添加了一些噪点,使图像具有某种旧照片的感觉。

(left) one of the images from ImageNet (right) black and white image with noise.
(左)来自ImageNet的图像之一(右)带有噪点的黑白图像。

预训练发生器 (Pre-train generator)

Now I have the dataset ready, I can start training. I created U-Net learner for the generator and pre-trained it before the GAN. It can be done easily by fastai library.

现在我已经准备好数据集,我可以开始训练了。 我为生成器创建了U-Net学习器,并在GAN之前对其进行了预培训。 可以通过fastai库轻松完成。

I started with a small size (64 pixel), so I can train it faster with a larger batch size.

我从一个小尺寸(64像素)开始,所以我可以以更大的批量来更快地训练它。

Generator pre-training with 64 pixel images.
生成器预训练,具有64个像素的图像。

Then I increased the size to 128 and 256. I started to see some good results with more epochs.

然后将大小增加到128和256。随着时间的推移,我开始看到一些不错的结果。

Generator pre-training with 128pixel images.
生成器具有128像素图像的预训练。
Generator pre-training with 256pixel images.
带有256像素图像的生成器预训练。

训练前鉴别器 (Pre-train discriminator)

After the generator pre-training, I used the generator to generate color photos from the black&white dataset. Then I used these generated photos and the original photos to train the discriminator.

在对生成器进行预训练之后,我使用生成器从黑白数据集中生成彩色照片。 然后,我使用这些生成的照片和原始照片来训练鉴别器。

After 10 epochs, the discriminator was able to tell if the image is generated with 85% accuracy.

经过10个时间段后,鉴别器便能够分辨出图像是否以85%的精度生成。

甘 (GAN)

Now it is time to put them together. Fastai provides a very useful tool for creating GAN, combining the pre-trained generator and discriminator. After 50 epoch training, I got my preliminary results.

现在是时候将它们放在一起了。 Fastai提供了一个非常有用的工具来创建GAN,将预训练的生成器和鉴别器结合在一起。 经过50历时的训练,我得到了初步结果。

GAN during training.
训练期间的GAN。

结果 (Results)

I downloaded some black and white photos which the model has not seen before for testing. Here are some of the results.

我下载了一些黑白照片,这些照片是该模型以前没有进行测试的。 这是一些结果。

The model is able to colorize the tree and grass. It also did a good job of colorizing human’s skin.

该模型能够为树木和草着色。 它还可以很好地使人的皮肤着色。

https://www.loc.gov/pictures/item/2016838246/) (right) colorized photo https://www.loc.gov/pictures/item/2016838246/ )(右)彩色照片
https://www.loc.gov/pictures/resource/cph.3c15477/?co=ggbain) (right) colorized photo https://www.loc.gov/pictures/resource/cph.3c15477/?co=ggbain )(右)彩色照片
https://www.loc.gov/item/2016878085/) (right) colorized photo https://www.loc.gov/item/2016878085/ )(右)彩色照片
https://www.loc.gov/pictures/resource/cph.3c35415/) (right) colorized photo https://www.loc.gov/pictures/resource/cph.3c35415/ )(右)彩色照片
https://www.loc.gov/pictures/resource/fsa.8b33922/) (right) colorized color https://www.loc.gov/pictures/resource/fsa.8b33922/ )(右)彩色
https://www.loc.gov/item/gottlieb.00201/) (right) colorized photo https://www.loc.gov/item/gottlieb.00201/ )(右)彩色照片
https://www.loc.gov/pictures/resource/cwpb.04351/) (right) colorized photo https://www.loc.gov/pictures/resource/cwpb.04351/ )(右)彩色照片

Some colors are not really realistic but still quite convincing.

有些颜色不是很真实,但仍然很有说服力。

https://www.loc.gov/pictures/item/2005685880/) (right) colorized photo https://www.loc.gov/pictures/item/2005685880/ )(右)彩色照片
https://www.loc.gov/pictures/resource/ggbain.00294/) (right) colorized photo https://www.loc.gov/pictures/resource/ggbain.00294/ )(右)彩色照片

Please be noted that this was trained by only 5000 images and not a lot of epoch, it might be improved further by doing more intensive training.

请注意,这仅通过5000张图像进行了训练,而且时间不多,可以通过进行更深入的训练来进一步改善。

Web应用程序 (Web Application)

A web app prototype can be quickly created using Streamlit. It does not require a lot of HTML and Java skills, so it is really helpful for web dummy like me.

可以使用Streamlit快速创建Web应用程序原型。 它不需要很多HTML和Java技能,因此对于像我这样的网络虚拟人真的很有帮助。

Web app built by Streamlit
由Streamlit构建的Web应用

Thanks for reading, suggestion, and feedback are welcome.

感谢您的阅读,建议和反馈。

更多示例: (More examples:)

https://www.loc.gov/resource/ppmsca.53290/) https://www.loc.gov/resource/ppmsca​​.53290/ )
https://www.loc.gov/resource/cph.3d01840/) https://www.loc.gov/resource/cph.3d01840/ )
https://www.loc.gov/resource/fsa.8c34879/) https://www.loc.gov/resource/fsa.8c34879/ )
https://www.loc.gov/resource/ppmsc.04884/) https://www.loc.gov/resource/ppmsc.04884/ )
https://www.loc.gov/resource/ppmsca.38847/) https://www.loc.gov/resource/ppmsca​​.38847/ )
https://www.loc.gov/resource/npcc.01561/) https://www.loc.gov/resource/npcc.01561/ )
https://www.loc.gov/resource/ggbain.16897/) https://www.loc.gov/resource/ggbain.16897/ )
https://www.loc.gov/resource/cph.3c15631/) https://www.loc.gov/resource/cph.3c15631/ )
https://www.loc.gov/item/2017863035/) https://www.loc.gov/item/2017863035/ )
https://www.loc.gov/item/2017801879/) https://www.loc.gov/item/2017801879/ )
https://www.loc.gov/resource/ggbain.16850/) https://www.loc.gov/resource/ggbain.16850/ )

翻译自: https://towardsdatascience.com/colorize-black-and-white-photos-by-ai-cc607e164160


http://www.taodudu.cc/news/show-6864553.html

相关文章:

  • 十多位机器学习专家联名推荐,这份书单不容错过!
  • 一文深入了解Linux IO 调度器
  • Extract Semantic Structure from Documents Using Multimodal Fully Convolutional Neural Networks阅读笔记
  • 【计算机视觉】实例感知图像着色 Instance-aware Image Colorization
  • [论文速览]:Multi-source Domain Adaptation for Semantic Segmentation
  • 2020 Top10计算机视觉论文总结:论文,代码,解读,还有demo视频!
  • 马蜂窝传年末裁员40%!离职n+2留下无年终,官方回应了!
  • 途牛最新财报再亏5.6亿,步子太大总会扯到蛋
  • 途牛被爆裁员400研发人员,惊呼遭血洗;苹果将于明年免收部分开发者的费用...
  • 苹果被罚每天交2.5万美元;“同一天出生的你”募捐遭质疑;途牛回应裁员风波丨价值早报
  • xx论文笔记:模板
  • 阅读论文记录模板
  • 08年 ,JavaScript总结
  • 【Python】积累与发现
  • yii的安全策略
  • python pyplot bar 参数_Python Matplotlib.pyplot.barh()用法及代码示例
  • html页面json转成对象吗,将HTML表单转换为JSON对象
  • 小數點的運算[討論區- PHP新手區] : 台灣PHP聯盟
  • 企业中台管理模式_中小企业的完整形式是什么?
  • MySQL基础增删改查
  • java 将单词转换为_在Java中将单词转换为数字
  • 实战React App的i18n
  • JavaScript 内置对象 BigInt
  • 芯片40174的作用
  • 非计算机行业转行后台开发入职字节跳动
  • 在外包做了3年,离职后成功入职字节跳动....
  • 软件测试人员如何快速提升自我?
  • 一口气拿了9家公司的offer,已拿offer入职
  • 〖编程初学者的自我修养 - 精炼面试篇①〗- 面试之前需要做的「长期准备工作」
  • 面试自我介绍整理

通过AI为黑白照片着色。相关推荐

  1. 日本早稻田大学的研究人员,使用AI给黑白照片着色

    对于怀旧的记忆来说,黑白照片确实在过去和现在之间形成了一定的隔阂. 当你翻开黑白相册,很容易遗忘我们与那个时代的联系,历史转瞬即逝. 由石川博士领导的早稻田大学研究小组,利用人工智能和深度学习技术,创 ...

  2. github怎么为代码着色_如何仅用100行神经网络代码为黑白照片着色

    github怎么为代码着色 by Emil Wallner 埃米尔·沃尔纳(Emil Wallner) 如何仅用100行神经网络代码为黑白照片着色 (How to colorize black &am ...

  3. 用AI给黑白照片上色,复现记忆中的旧时光

    https://blog.csdn.net/dqcfkyqdxym3f8rb0/article/details/82393433 作者 | Rajat 译者 | 婉清 编辑 | Jane 出品 | A ...

  4. 独立产品灵感周刊 DecoHack #031 - 用 AI 给黑白照片上色哪家好?

    本周刊记录有趣好玩的独立产品设计开发相关内容,每周发布,往期内容同样精彩,感兴趣的伙伴可以点击订阅我的周刊.为保证每期都能收到,建议邮件订阅.欢迎通过 Twitter 私信推荐或投稿. 产品推荐 1. ...

  5. 使用Photoshop给黑白照片着色变彩色相片实例教程

    很多人都有一些多年前拍的黑白照片,过了许多年照片老了旧了,特别是那些历史已久远的相片已变得破损不堪.有没有办法将黑白照片修复并给其着色变身成怀旧的彩色相片呢?这是完全可能的,今天一起来看个Photos ...

  6. Python图像增强与特效-利用百度AI进行黑白图像上色

    一.接口描述 智能识别黑白图像内容并填充色彩,使黑白图像变得鲜活. 二.使用攻略 请求说明 请求示例 HTTP 方法:POST 请求URL: https://aip.baidubce.com/rest ...

  7. 如何在Photoshop中为黑白老式照片着色

    Ever wanted to add color to your old, vintage, or historical photographs? Load up some old pictures ...

  8. ai css 线条粗细_如何训练AI将您的设计模型转换为HTML和CSS

    ai css 线条粗细 by Emil Wallner 埃米尔·沃尔纳(Emil Wallner) 如何训练AI将您的设计模型转换为HTML和CSS (How you can train an AI ...

  9. 新年快乐!这是份值得收藏的2017年AI与深度学习要点大全

    若朴 夏乙 编译自 WILDML 量子位 出品 | 公众号 QbitAI 2017已经正式离我们远去. 过去的一年里,有很多值得梳理记录的内容.博客WILDML的作者.曾在Google Brain做了 ...

最新文章

  1. JS获取鼠标位置,兼容IE FF
  2. Boost::context模块fiber的斐波那契测试程序
  3. ad19pcb所有元件都在报错_PLC的线圈输出和置复位,可以混用吗?很多人都会犯这个错误!...
  4. OpenShift上的无痛集装箱化JBoss通用贷款处理
  5. 滴滴 KDD 2018 论文详解:基于强化学习技术的智能派单模型
  6. java二叉树深度优先遍历会考不递归的吗_树的广度优先遍历和深度优先遍历(递归非递归、Java实现)...
  7. php源码下载 uctoo_uctoo
  8. java实现 mysql导入_怎么用java实现mysql数据库的导入导出
  9. Matlab深度学习上手初探
  10. 学习笔记(01):19年录制Zookeeper、Dubbo视频教程 微服务教程分布式教程 SpringBoot教程整合-技术选型和学后水平...
  11. 正态分布、t分布、卡方分布、F分布的关系与差异
  12. 神经网络机器翻译的实现
  13. 某程序员披露华为外包员工现状:工作氛围好,没有歧视,但转正后也不算正式员工?...
  14. Docker 之 基操
  15. Win32_DiskDrive 硬盘 参数说明
  16. 会计记账公式、六要素、记账流程
  17. 遗忘曲线艾宾浩斯规律
  18. python绘制太阳系_如何利用Python动态模拟太阳系运转
  19. hexo设置网站的图标Favicon
  20. 计算机竞聘演讲稿,竞聘农业银行计算机主任演讲稿

热门文章

  1. 2020年写给自己的一封信
  2. 揭秘阿里云IoT安全平台Link Security如何实现物联网产品全生命周期管理
  3. 软件测试在IT行业里真的是最底层嘛?
  4. linux grep +输入输出
  5. 安卓桌面壁纸_三星安卓11刚内测,然而国产旗舰早已用上
  6. WIN7及以上系统如何输入序列号并激活成正式版?
  7. java之影流之主( 流 )第十六天( --装饰者模式--LineNumberReader-)
  8. 使用do-while实现:输出摄氏温度与华氏温度的对照表,要求它从摄氏温度0度到250度,每隔20度为一项,对照表中的条目不超过10条。
  9. fzu月赛(2015.11)
  10. 使用python+Tkinter做一个自动关机的图形界面