主页 > 其他 > 照片修复、增强类开源项目

照片修复、增强类开源项目

2023年2月12日 照片修复、增强类开源项目无评论 阅读: 17,132 次

人脸修复项目:

6

图片内容删除、替换项目:

6

老照片修复项目:

6

 

一、CodeFormer

1、安装

首先需要安装Python和git,注意Python版本需要64位版本,可以是3.9或3.10

然后安装pytorch,安装指令参考,可以用显卡CUDA加速或CPU解码:

6

可用pip安装,linux下安装指令,CPU解码

pip3 install torch torchvision torchaudio

克隆项目库

git clone https://github.com/sczhou/CodeFormer
cd CodeFormer

安装依赖库

pip3 install -r requirements.txt
python basicsr/setup.py develop

下载预训练模型

python scripts/download_pretrained_models.py facelib
python scripts/download_pretrained_models.py dlib
python scripts/download_pretrained_models.py CodeFormer

安装完成
2、使用
1)人脸恢复
一般用于单个人脸修复

python inference_codeformer.py -w 0.5 --has_aligned --input_path [image folder]|[image path]

可用指定修复的图片目录或图片,如
python inference_codeformer.py -w 0.5 --has_aligned --input_path /root/CodeFormer/inputs/cropped_faces/0763.png
python inference_codeformer.py -w 0.5 --has_aligned --input_path /root/CodeFormer/inputs/test
2)整体图像增强 一般用于多个人脸修复

# For whole image
# Add '--bg_upsampler realesrgan' to enhance the background regions with Real-ESRGAN
# Add '--face_upsample' to further upsample restorated face with Real-ESRGAN
python inference_codeformer.py -w 0.7 --input_path [image folder]|[image path]

例如

python inference_codeformer.py -w 0.7 --input_path /root/CodeFormer/inputs/test/1.png

3)视频增强
需ffmpeg支持


# For video clips
# video path should end with '.mp4'|'.mov'|'.avi'
python inference_codeformer.py --bg_upsampler realesrgan --face_upsample -w 1.0 --input_path [vide path]

W是保真度权重 ,取值为 0-1之间。 通常,较小的 w 往往会产生较高质量的结果,而较大的 w 会产生较高保真度的结果。

恢复效果:

腾讯有类似的开源项目:

6

 

二、lama-cleaner

Lama Cleaner 是由 SOTA AI 模型提供支持的免费开源图像修复工具。使用 Lama Cleaner 可以从照片中删除任何不需要的物体、缺陷、人物或擦除和替换(由稳定扩散驱动)照片上的任何东西。

主要功能:

删除图像上不需要的东西;
修复旧照片;
替换图片上的东西;

1、安装

指定cpu解码,在8080端口运行服务

pip install lama-cleaner
lama-cleaner --model=lama --device=cpu --port=8080 --host=0.0.0.0

更多参数

Name Description Default
--model lama/ldm/zits/mat/fcf/sd1.5/manga/sd2/paint_by_example lama
--model-dir Model download directory (by setting XDG_CACHE_HOME environment variable), by default model downloaded to ~/.cache" lama
--device cuda / cpu / mps cuda
--sd-disable-nsfw Disable stable-diffusion NSFW checker.
--sd-cpu-textencoder Always run stable-diffusion TextEncoder model on CPU.
--sd-enable-xformers Enable xFormers optimizations. See: facebookresearch/xformers(opens in a new tab)
--local-files-only Once the model as downloaded, you can pass this arg to avoid diffusers connect to Hugging Face server
--cpu-offload sd/paint_by_example model. With cpu offload sd model only needs 2GB GPU memory (image size 512x512)
--no-half Using full precision for sd/paint_by_exmaple model. If your generate result is always, use this
--host Set to 0.0.0.0 if you want to visit the server on another device localhost
--port Port for backend flask web server 8080
--gui Launch lama-cleaner as a desktop application
--gui_size Set the window size for the application 1200 900
--input Path to image/directory you want to load by default None
--debug Enable debug mode for flask web server
使用方法也很简单,浏览器登录端口服务,然后擦去不需要的图片部分即可:

三、Bringing-Old-Photos-Back-to-Life

先看宣传效果

1、安装

待续。。。

发表评论

新用户的评论需审核后才会显示;

电子邮件地址不会被公开;
必填项已用*标注