架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

搜索
查看: 210|回复: 0

[资料] .NET 调用 DeOldify.NET 使图像着色(老照片修复)

[复制链接]
发表于 2024-12-13 15:54:51 | 显示全部楼层 |阅读模式
需求:前几年看到了一些关于老照片修复的文章,就是讲黑白照片转换成彩色照片。一些都是基于 DeOldify 实现,今天有时间研究一下。

DeOldify 项目地址:https://github.com/jantic/DeOldify

看项目的介绍,推荐了一个 .NET 版本的,地址:https://github.com/ColorfulSoft/DeOldify.NET,本文尝试使用 DeOldify.NET 进行测试。

克隆项目,命令如下:



根据自己需求运行相应的编译脚本:

Build
Details
Script
Artistic
Basic version of Artistic colorizer with float16 weights
Compile.artistic.bat
Artistic.w32
Artistic colorizer with float32 weights
Compile.artistic.float.bat
Artistic.simd
Artistic colorizer with SIMD acceleration and float16 weights
Compile.artistic.simd.bat
Artistic.simd.w32
Artistic colorizer with SIMD acceleration and float32 weights
Compile.artistic.simd.float.bat
Stable
Basic version of Stable colorizer with float16 weights
Compile.stable.bat
Stable.w32
Stable colorizer with float32 weights
Compile.stable.float.bat
Stable.simd
Stable colorizer with SIMD acceleration and float16 weights
Compile.stable.simd.bat
Stable.simd.w32
Stable colorizer with SIMD acceleration and float32 weights
Compile.stable.simd.float.bat


本文以 Stable.simd.w32 为例子,运行 Compile.stable.simd.float.bat 脚本,别着急执行!别着急执行!别着急执行!

在执行之前,先下载模型,地址:https://github.com/ColorfulSoft/DeOldify.NET/releases/download/Weights/Stable.model

仓库有 4 个模型,大小分别如下,根据自己需求进行下载即可:

QQ截图20241213152650.jpg

将下载的 Stable.model 文件放在 Implementation\src\Resources 文件夹下载,由于源码是将模型以嵌入的资源打包至应用程序,会非常大,所以,我们需要修改一下源码。

修改"Implementation\src\DeOldify.cs"代码,如下:



还要修改"Implementation\Windows.stable.simd.float.rsp" 文件,将如下配置删除



最后,执行 Compile.stable.simd.float.bat 脚本,编译完成,文件大小最终为 1.7 M,原来要 800M+。编译后的文件在 Release 文件夹下面,同时,需要在该文件夹下面新建 Resources 文件夹,并将 Stable.model 文件放入该目录。

运行“DeOldify.NET.stable.windows.simd.w32.exe”程序,从网上随便找了一张黑白照片,测试如下图:

QQ截图20241213155237.jpg

原图和处理后图片对比如下:

QQ截图20241213155343.jpg

成品下载:

游客,如果您要查看本帖隐藏内容请回复




上一篇:NUC 支持 ECC 内存的机器
下一篇:Windows 使用 tar 对文件夹进行压缩打包
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2025-1-17 01:53

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表