如何将照片美化,DPED机器学习开源项目安装使用 | 机器学习
目录
前言
环境部署
项目结构
tensorflow安装
其他依赖安装
VGG-19下载
项目运行
准备图片素材
测试效果
总结
前言
最近发现了一个可以把照片美化的项目,自己玩了玩,挺有意思的,分享一下。
Github地址:DPED项目地址
下面来看看项目怎么玩?先放一些项目给出的效果图。可以看出照片更明亮好看了。
环境部署
项目结构
下面是项目的原始结构:
tensorflow安装
按照项目的说明,我们需要安装tensorflow以及一些必要的库。
如果安装gpu版本的tensorflow需要对照一下
tensorflow官方对照地址:TensorFlow官方CUDA版本对照
我的cuda是11.1的版本,按照tensorflow后还是缺少部分dll,如果有相同问题的,可以用我提供的资源包: https://pan.baidu.com/s/1IUm8xz5dhh8iW_bLWfihPQ 提取码:TUAN。
缺少哪个dll,直接复制到你的NVIDIA GPU Computing Toolkit目录对应cuda的bin目录下。
按照自己的版本来,我的tensorflow命令如下:
pip install tensorflow-gpu==2.4.2 -i https://pypi.douban.com/simple
pip install tf-nightly -i https://pypi.douban.com/simple
其他依赖安装
Pillow, scipy, numpy, imageio安装
pip install Pillow -i https://pypi.douban.com/simple
pip install scipy -i https://pypi.douban.com/simple
pip install numpy -i https://pypi.douban.com/simple
pip install imageio -i https://pypi.douban.com/simple
VGG-19下载
因为模型文件太大,github的项目中无法上传这么大的文件,作者让我们自己下。
我把DPED的资源包统一打包了,也可以从我的云盘下载, 放到项目的vgg_pretrained目录下。下图是资源包的目录
资源包地址: https://pan.baidu.com/s/1IUm8xz5dhh8iW_bLWfihPQ 提取码:TUAN。
项目运行
项目需要的环境我们都装好了,我们跳过训练的部分,测试model的方法官方给出了命令。
准备图片素材
我准备了几张图,就不全展示了,展示其中的一张。
按照项目的要求,需要放在对应的目录下。
测试效果
执行命令
python test_model.py model=iphone_orig test_subset=full resolution=orig use_gpu=true
执行过程
(tensorflow) C:\Users\yi\PycharmProjects\DPED>python test_model.py model=iphone_orig test_subset=full resolution=orig use_gpu=true
2021-11-27 23:42:57.922965: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-11-27 23:43:00.532645: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to
use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-11-27 23:43:00.535946: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2021-11-27 23:43:00.559967: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1070 computeCapability: 6.1
coreClock: 1.759GHz coreCount: 15 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s
2021-11-27 23:43:00.560121: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-11-27 23:43:00.577706: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-11-27 23:43:00.577812: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-11-27 23:43:00.588560: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-11-27 23:43:00.591950: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-11-27 23:43:00.614412: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-11-27 23:43:00.624267: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-11-27 23:43:00.626309: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-11-27 23:43:00.626481: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-11-27 23:43:01.112598: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-11-27 23:43:01.112756: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0
2021-11-27 23:43:01.113098: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N
2021-11-27 23:43:01.113463: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6720 MBmemory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)
2021-11-27 23:43:01.114296: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
WARNING:tensorflow:From C:\Users\yi\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\compat\v2_compat.py:96: disable_resource_variables (from tensorflow.p
ython.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
2021-11-27 23:43:01.478512: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-11-27 23:43:01.479339: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1070 computeCapability: 6.1
coreClock: 1.759GHz coreCount: 15 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s
2021-11-27 23:43:01.479747: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-11-27 23:43:01.480519: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-11-27 23:43:01.480927: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-11-27 23:43:01.481155: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-11-27 23:43:01.481568: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-11-27 23:43:01.481823: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-11-27 23:43:01.482188: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-11-27 23:43:01.482416: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-11-27 23:43:01.482638: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-11-27 23:43:01.482959: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1070 computeCapability: 6.1
coreClock: 1.759GHz coreCount: 15 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s
2021-11-27 23:43:01.483077: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-11-27 23:43:01.483254: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-11-27 23:43:01.483426: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-11-27 23:43:01.483638: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-11-27 23:43:01.483817: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-11-27 23:43:01.484052: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-11-27 23:43:01.484250: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-11-27 23:43:01.484433: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-11-27 23:43:01.484662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-11-27 23:43:01.484841: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-11-27 23:43:01.484984: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0
2021-11-27 23:43:01.485152: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N
2021-11-27 23:43:01.485395: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6720 MBmemory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)
2021-11-27 23:43:01.485565: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-11-27 23:43:01.518135: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:196] None of the MLIR optimization passes are enabled (registered 0 passes)
Testing original iphone model, processing image 3.jpg
2021-11-27 23:43:01.863678: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-11-27 23:43:02.517063: I tensorflow/core/platform/windows/subprocess.cc:308] SubProcess ended with return code: 02021-11-27 23:43:02.632790: I tensorflow/core/platform/windows/subprocess.cc:308] SubProcess ended with return code: 02021-11-27 23:43:03.210892: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-11-27 23:43:03.509052: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
Lossy conversion from float32 to uint8. Range [-0.06221151351928711, 1.0705437660217285]. Convert image to uint8 prior to saving to suppress this warning.
Lossy conversion from float32 to uint8. Range [-0.06221151351928711, 1.0705437660217285]. Convert image to uint8 prior to saving to suppress this warning.
Testing original iphone model, processing image 4.jpg
Lossy conversion from float32 to uint8. Range [-0.05176264047622681, 1.0500218868255615]. Convert image to uint8 prior to saving to suppress this warning.
Lossy conversion from float32 to uint8. Range [-0.05176264047622681, 1.0500218868255615]. Convert image to uint8 prior to saving to suppress this warning.
Testing original iphone model, processing image 5.jpg
Lossy conversion from float32 to uint8. Range [-0.03344374895095825, 1.0417983531951904]. Convert image to uint8 prior to saving to suppress this warning.
Lossy conversion from float32 to uint8. Range [-0.03344374895095825, 1.0417983531951904]. Convert image to uint8 prior to saving to suppress this warning.
Testing original iphone model, processing image 6.jpg
Lossy conversion from float32 to uint8. Range [-0.03614246845245361, 1.063475251197815]. Convert image to uint8 prior to saving to suppress this warning.
Lossy conversion from float32 to uint8. Range [-0.03614246845245361, 1.063475251197815]. Convert image to uint8 prior to saving to suppress this warning.
项目会生成前后对比图以及最终结果图。
前后效果图,左边为原始图,右边为对比图。
结果图如下
可以明显的看出,新图已经明亮了许多,色彩也变的比较鲜明了,效果还是很不错的。
总结
项目整体没什么毛病,只是如果要单独处理一张图片还需要对项目魔改一下。我下一篇文章会稍微魔改一下,简化项目结构,处理单张图片。
分享:
有花不语,凌风傲雪。有花不言,自开自凋零。有花幽幽,芳华尽蚀人间。——《虫师》
如果本文对你有用的话,给我点个赞吧,谢谢!
如何将照片美化,DPED机器学习开源项目安装使用 | 机器学习相关推荐
- AI让照片换发型,Barbershop开源项目安装使用 | 机器学习
目录 前言 环境部署 1.导入environment/environment.yaml环境 2.安装pytorch 3.依赖库安装 4. cl.exe环境变量配置 5.模型下载 6.发型数据下载 7. ...
- 如何调整照片人物年龄,此生也算共白头,PaddleGAN开源项目安装使用 | 机器学习
目录 前言 环境部署 项目使用 预处理部分 照片老化处理 照片年轻化处理 总结 前言 最近在试着研究飞浆平台的许多功能,看到了许多有意思的功能.其中可以将照片美化以及年龄调整这个功能让我想到了之前抖音 ...
- AI识别照片是谁,人脸识别face_recognition开源项目安装使用 | 机器学习
目录 前言 环境安装 代码使用 总结 前言 最近碰到了照片识别的场景,正好使用了face_recognition项目,给大家分享分享.face_recognition项目能做的很多,人脸检测功能也是有 ...
- 机器学习必备:前20名Python人工智能和机器学习开源项目
摘要: 机器学习之旅必了解:前20名Python人工智能和机器学习开源项目! 如今机器学习和人工智能已经变得家喻户晓,有很多爱好者进入了该领域.但是,什么才是能够进入该领域的正确路径呢?如何保持自己跟 ...
- 机器学习开源项目Top10
整理 | Jane 出品 | AI科技大本营 [导语]又到了我们固定给大家推荐开源项目的时间.本期将为大家推荐 10 个机器学习开源项目,统计了过去一个月中 250 个机器学习开源项目,并从中选取了本 ...
- 11月最佳机器学习开源项目Top10!
整理 | Jane 出品 | AI科技大本营 过去一个月,我们从近 250 个机器学习开源项目中挑选出了最受大家关注的前十名.这些项目在 GitHub 上平均 Stars 数为 2713.这些项目涉及 ...
- 10月机器学习开源项目Top10
作者 | Mybridge 译者 | 林春眄 整理 | Jane 出品 | AI科技大本营 [导读]过去一个月里,我们对近 250 个机器学习开源项目进行了排名,并挑选出热度前 10 的项目.这份清单 ...
- 9月机器学习开源项目Top10
作者 | Mybridge 译者 | 王天宇 整理 | Jane 出品 | AI科技大本营 [导读]我们从过去一个月近 250 个有关机器学习的开源项目中,精心挑选出了最热门的 10 个.在挑选过程中 ...
- 精选机器学习开源项目Top10
作者 | Mybridge 译者 | linstancy 编辑 | Jane 出品 | AI科技大本营 [导读]过去一个月里,我们对近 250 个机器学习开源项目进行了排名,并挑选出热度前 10 的项 ...
最新文章
- SCSF 系列:Smart Client Software Factory 启动过程详解
- 使用border-color设置输入框边框颜色后颜色不一致(左上边自动深色)解决方案
- 文件及文件组备份与还原示例.sql
- c# winform窗体如何设置才可以不能随意拖动大小
- 我精心珍藏的Python代码技巧
- Oracle 19c RAC打补丁过程避坑指南
- org.slf4j.Logger中isTraceEnabled(),isDebugEnabled(),isInfoEnabled(),isWarnEnabled(),isErrorEnabled()
- 从排序开始(三)归并排序
- 【PCB学习笔记】绘制智能车四层板 --- DRC检查,拼版设计及资料输出
- vue 中基于drag drop拖放实现左菜单和右画布的功能
- 帝国cms如何给网站添加百度统计代码,百度统计安装教程步骤分享
- django完成一个可重用注册登录系统
- Currency Trading: Dollar in a Funk as Traders Bet on Slow Rebound
- 如何讲述个人职业生涯
- BUUCTF_Crypto_异性相吸(yxxx)
- 奥鹏福建师范大学2021年2月考试《计算机应用基础》作业56754
- 二叉树前中后序遍历+刷题【中】【数据结构/初阶/C语言实现】
- Struts2 框架学习第三天笔记
- qnx与linux区别,实时Linux和RTOS进行比较
- 计算机叫醒服务英语,总算发现叫醒服务英语怎么说
热门文章
- 分享8年开发经验,浅谈java程序员职业规划
- 大数据系列修炼-Scala课程96(2)
- Walgreens以myWalgreens重塑美国最大的卫生健康忠诚度计划,为顾客带来更加丰富的福利
- 论文笔记(十二):Particle Filter Networks: End-to-End Probabilistic Localization From Visual Observations
- LAMP网站性能优化
- 调试 QML 应用程序
- 精益生产之标准工时制度及管理办法
- 用生物统计学技术控制网络接入
- php+mysql婚纱摄影网站的设计与实现
- 百万博主之星,帅地被吐槽开挂了?