目录:
脚本代码
使用要求
使用说明
补充说明
脚本代码
#处理器文件存放位置
$processor = "F:\realesrgaimage\realesrgan-ncnn-vulkan-20211212-windows"
# 设定输入图片的文件夹
$inImagePath = ".\input"
# 设定输出图片的文件夹
$outImagePath = ".\output"
#选择处理模型,动漫模型扣1,正常扣2
do
{
$judge = Read-Host "选择默认模型处理扣1,动漫模型处理扣2,net模型扣3。"
switch($judge)
{
1{
write-host "============选择默认模型==========" -ForegroundColor Red
$useProcessor = "realesrgan-x4plus"
}
2{
write-host "============选择动漫模型==========" -ForegroundColor Red
$useProcessor = "realesrgan-x4plus-anime"
}
3{
write-host "============选择动realesrnet-x4plus模型==========" -ForegroundColor Red
$useProcessor = "realesrnet-x4plus"
}
default{
write-host "============别瞎鸡儿乱扣数字行不,不想选可以Ctrl+C退出去,别找茬(▼皿▼#)==========" -ForegroundColor Red
$useProcessor = 5
}
}
}while ( $useProcessor -eq 5 )
#跳转到应用程序
cd $processor
# 使用Get-ChildItem命令获取文件夹内的所有项,并使用-Name参数只输出文件名
$fileNames = Get-ChildItem -Path $inImagePath -Name
# 提示开始处理
write-host "============( = A = )处理,启动!!!==========" -ForegroundColor Red
# forEach循环执行处理命令
foreach ($fileName in $fileNames) {
$var = 1
write-host "--------------------------------------现在正在处理第 $var 张图片,图片名称为$fileName--------------------------------------" -ForegroundColor Yellow
./realesrgan-ncnn-vulkan.exe -i $inImagePath\$fileName -o $outImagePath\$fileName -n $useProcessor
$var = $var +1
}
#结束提示语
write-host "============(›´ω`‹ )一张都没有力==========" -ForegroundColor Blue
使用要求
使用软件版本
本人用的是上面的版本号,不知道版本的在使用说明里面看说明使用的命令和模型!:
使用的模型
使用说明
1,创建一个txt文档,将上面所有代码复制粘贴上去,然后将文件后缀修改成ps1(powershell的脚本文件后缀)
2,修改路径,将脚本标绿的路径修改成自己电脑存放的路径
3,再这个路径下创建两个文件夹,并分别命名为input和output
结果如上
最后将需要处理的图片放到input文件夹中,win+R启动powershell,再启动脚本就OK了
脚本成功运行
补充说明
1,如果运行时出现乱码的话,是因为编码问题,参考这个http://t.csdnimg.cn/29PQK
2,有可能会因为版本低出现报错,就提示缺少 } 什么的话,把下面的蓝色do,while代码删掉,再把
./realesrgan-ncnn-vulkan.exe -i $inImagePath\$fileName -o $outImagePath\$fileName -n $useProcessor
改成
./realesrgan-ncnn-vulkan.exe -i $inImagePath\$fileName -o $outImagePath\$fileName -n realesrgan-x4plus-anime
(红色加粗就是选择自己需要的模型)
原因我推测是因为低版本powershell没有do-while函数
do
{
$judge = Read-Host "选择默认模型处理扣1,动漫模型处理扣2,net模型扣3。"
switch($judge)
{
1{
write-host "============选择默认模型==========" -ForegroundColor Red
$useProcessor = "realesrgan-x4plus"
}
2{
write-host "============选择动漫模型==========" -ForegroundColor Red
$useProcessor = "realesrgan-x4plus-anime"
}
3{
write-host "============选择动realesrnet-x4plus模型==========" -ForegroundColor Red
$useProcessor = "realesrnet-x4plus"
}
default{
write-host "============别瞎鸡儿乱扣数字行不,不想选可以Ctrl+C退出去,别找茬(▼皿▼#)==========" -ForegroundColor Red
$useProcessor = 5
}
}
}while ( $useProcessor -eq 5 )
————————————————————————————————————————
补充一下,本人在尝试后发现提示缺少 } 什么的错误,是因为编辑器无法识别中文,导致识别不到这个 “ } ”,解决方法就是将do while函数注释掉后,在把$useProcessor改为自己需要的模型,也就是补充说明第二点。
或者参考这个http://t.csdnimg.cn/29PQK ,将时间改动,但是这样子会使其他应用产生可能无法识别需要文件,导致无法运行启动的错误