图像的风格迁移,心心念念好久了啊!
简单几个步骤,就可以转换图片风格啦。
1. 在github下载模型,模型后缀名是 t7,新建 model 文件夹用来存放模型
图像风格迁移模型链接
2. 新建 fengge.py 文件,代码如下:
import cv2 as cv
import numpy as np
import argparse
parser = argparse.ArgumentParser(
description='This script is used to run style transfer models from '
'https://github.com/jcjohnson/fast-neural-style using OpenCV')
parser.add_argument('--input', help='Path to image or video. Skip to capture frames from camera')
parser.add_argument('--model', help='Path to .t7 model')
parser.add_argument('--width', default=-1, type=int, help='Resize input to specific width.')
parser.add_argument('--height', default=-1, type=int, help='Resize input to specific height