当前位置:网站首页>图片上色项目 —— Deoldify
图片上色项目 —— Deoldify
2022-07-06 09:13:00 【zkkkkkkkkkkkkk】
目录
一、拉取Deoldify项目代码
git地址:https://github.com/jantic/DeOldify
二、下载预训练模型
2.1、步骤
1)在项目根目录创建models文件夹
2)下载预训练模型文件,将三个文件上传至models目录
三、图片上色
from deoldify import device
from deoldify.device_id import DeviceId
from deoldify.visualize import *
from pathlib import Path
import os
os.environ['KMP_DUPLICATE_LIB_OK'] = "TRUE"
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
#choices: CPU, GPU0...GPU7
device.set(device=DeviceId.GPU0)
plt.style.use('dark_background')
torch.backends.cudnn.benchmark=True
render_factor=35
result_path = None
p = Path('D:\\Gitlab\\DeOldify\\test_images')
all_file_path = []
count = 0
for file_name in p.rglob('*.jpg'):
all_file_path.append(file_name)
count+=1
for file_name in p.rglob('*.png'):
all_file_path.append(file_name)
count+=1
for file_name in p.rglob('*.jppeg'):
all_file_path.append(file_name)
count+=1
print(f"遍历待上色文件夹结束,共有{count}个图片文件\n")
# 遍历图片,上色
for img_file_path in all_file_path:
# arctan
colorizer = get_image_colorizer(artistic=True)
img_file_name = str(img_file_path).split('\\')[-1]
print(f"开始处理{img_file_name}")
colorizer.plot_transformed_image(path=img_file_path, render_factor=render_factor, compare=True)
print(f"{img_file_name}处理结束")
print("\n")
# 结束
print("图片上色程序结束")
四、视频上色
from deoldify import device
from deoldify.device_id import DeviceId
from deoldify.visualize import *
plt.style.use('dark_background')
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
#choices: CPU, GPU0...GPU7
device.set(device=DeviceId.GPU0)
colorizer = get_video_colorizer()
#NOTE: Max is 44 with 11GB video cards. 21 is a good default
render_factor=21
result_path = None
file_name_ext = 'D:\\Gitlab\\DeOldify\\test_video\\test1.mp4'
colorizer.colorize_from_file_name(file_name_ext, render_factor=render_factor)
边栏推荐
- FRP intranet penetration
- CSDN blog summary (I) -- a simple first edition implementation
- Solution: log4j:warn please initialize the log4j system properly
- There are three iPhone se 2022 models in the Eurasian Economic Commission database
- Windchill configure remote Oracle database connection
- Timestamp with implicit default value is deprecated error in MySQL 5.6
- Swagger, Yapi interface management service_ SE
- Win10: how to modify the priority of dual network cards?
- Yum prompt another app is currently holding the yum lock; waiting for it to exit...
- ++Implementation of I and i++
猜你喜欢
API learning of OpenGL (2002) smooth flat of glsl
CSDN question and answer tag skill tree (I) -- Construction of basic framework
csdn-Markdown编辑器
Valentine's Day is coming, are you still worried about eating dog food? Teach you to make a confession wall hand in hand. Express your love to the person you want
CSDN blog summary (I) -- a simple first edition implementation
Opencv uses freetype to display Chinese
Leetcode 461 Hamming distance
Mysql34 other database logs
连接MySQL数据库出现错误:2059 - authentication plugin ‘caching_sha2_password‘的解决方法
[ahoi2009]chess Chinese chess - combination number optimization shape pressure DP
随机推荐
SSM integrated notes easy to understand version
Kubesphere - deploy the actual combat with the deployment file (3)
Mysql35 master slave replication
Mysql 其他主机无法连接本地数据库
Leetcode 461 Hamming distance
Global and Chinese markets for aprotic solvents 2022-2028: Research Report on technology, participants, trends, market size and share
[recommended by bloggers] C WinForm regularly sends email (with source code)
Swagger, Yapi interface management service_ SE
Ansible实战系列三 _ task常用命令
Generate PDM file from Navicat export table
February 13, 2022-3-middle order traversal of binary tree
Mysql33 multi version concurrency control
Global and Chinese market for intravenous catheter sets and accessories 2022-2028: Research Report on technology, participants, trends, market size and share
Remember a company interview question: merge ordered arrays
Windows cannot start the MySQL service (located on the local computer) error 1067 the process terminated unexpectedly
CSDN问答模块标题推荐任务(一) —— 基本框架的搭建
windows无法启动MYSQL服务(位于本地计算机)错误1067进程意外终止
Esp8266 at+cipstart= "", "", 8080 error closed ultimate solution
Database middleware_ MYCAT summary
导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法