使用AI工具Lama Cleaner一键去除水印、人物、背景等图片里的内容

前言

前提条件

相关介绍

  • Python是一种跨平台的计算机程序设计语言。是一个高层次的结合了解释性、编译性、互动性和面向对象的脚本语言。最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越多被用于独立的、大型项目的开发。
  • PyTorch 是一个深度学习框架,封装好了很多网络和深度学习相关的工具方便我们调用,而不用我们一个个去单独写了。它分为 CPU 和 GPU 版本,其他框架还有 TensorFlow、Caffe 等。PyTorch 是由 Facebook 人工智能研究院(FAIR)基于 Torch 推出的,它是一个基于 Python 的可续计算包,提供两个高级功能:1、具有强大的 GPU 加速的张量计算(如 NumPy);2、构建深度神经网络时的自动微分机制。
  • Lama Cleaner是一款完全免费开源,而且没有人分辨率限制的图片去水印、修复工具:Lama Cleaner,内置了多种AI 模型构建,功能相当的齐全。可用于快速去除图像中各种水印、物品、人物、字体、等图像里的内容。

Lama Cleaner

环境要求

  • torch>=1.9.0
  • opencv-python
  • flask==2.2.3
  • flask-socketio
  • simple-websocket
  • flask_cors
  • flaskwebgui==0.3.5
  • pydantic
  • rich
  • loguru
  • yacs
  • diffusers==0.16.1
  • transformers==4.27.4
  • gradio
  • piexif==1.1.3
  • safetensors
  • omegaconf
  • controlnet-aux==0.0.3

安装Lama Cleaner

  • pip安装前,需要安装Python环境
pip install lama-cleaner
或者
pip install lama-cleaner -i https://pypi.tuna.tsinghua.edu.cn/simple # 使用国内镜像源,下载速度更快。

在这里插入图片描述
在这里插入图片描述

启动Lama Cleaner

CPU方式启动

lama-cleaner --model=lama --device=cpu --port=8080 

GPU方式启动

## 本机浏览
lama-cleaner --model=lama --device=cuda --port=8080 --model-dir E:\mytest\lama_cleaner\weight
## 局域网内浏览
lama-cleaner --model=lama --device=cuda --port=8080 --model-dir E:\mytest\lama_cleaner\weight --host 0.0.0.0 

在这里插入图片描述

在这里插入图片描述

使用Lama Cleaner

  • 在浏览器打开网址:http://IP地址:8080
    在这里插入图片描述
    在这里插入图片描述

测试结果

NO.1 检测框
  1. 打开要原图片
    在这里插入图片描述
  2. 按住鼠标,去除图片内的内容(黄色轨迹)
    在这里插入图片描述
  3. 效果图
    在这里插入图片描述
NO.2 水印
  1. 打开要原图片
    在这里插入图片描述
  2. 按住鼠标,去除图片内的内容(黄色轨迹)
    在这里插入图片描述
  3. 效果图
    在这里插入图片描述
NO.3 广州塔
  1. 打开要原图片
    在这里插入图片描述

  2. 按住鼠标,去除图片内的内容(黄色轨迹)
    在这里插入图片描述

  3. 效果图
    在这里插入图片描述

NO.4 人物背景
  1. 打开要原图片
    在这里插入图片描述

  2. 按住鼠标,去除图片内的内容(黄色轨迹)
    在这里插入图片描述

  3. 效果图
    在这里插入图片描述

参考

[1] https://github.com/Sanster/lama-cleaner.git

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
解释这些参数optional arguments: -h, --help show this help message and exit --host HOST --port PORT --config-installer Open config web page, mainly for windows installer (default: False) --load-installer-config Load all cmd args from installer config file (default: False) --installer-config INSTALLER_CONFIG Config file for windows installer (default: None) --model {lama,ldm,zits,mat,fcf,sd1.5,cv2,manga,sd2,paint_by_example,instruct_pix2pix} --no-half Using full precision model. If your generate result is always black or green, use this argument. (sd/paint_by_exmaple) (default: False) --cpu-offload Offloads all models to CPU, significantly reducing vRAM usage. (sd/paint_by_example) (default: False) --disable-nsfw Disable NSFW checker. (sd/paint_by_example) (default: False) --sd-cpu-textencoder Run Stable Diffusion text encoder model on CPU to save GPU memory. (default: False) --local-files-only Use local files only, not connect to Hugging Face server. (sd/paint_by_example) (default: False) --enable-xformers Enable xFormers optimizations. Requires xformers package has been installed. See: https://github.com/facebookresearch/xformers (sd/paint_by_example) (default: False) --device {cuda,cpu,mps} --gui Launch Lama Cleaner as desktop app (default: False) --no-gui-auto-close Prevent backend auto close after the GUI window closed. (default: False) --gui-size GUI_SIZE GUI_SIZE Set window size for GUI (default: [1600, 1000]) --input INPUT If input is image, it will be loaded by default. If input is directory, you can browse and select image in file manager. (default: None) --output-dir OUTPUT_DIR Result images will be saved to output directory automatically without confirmation. (default: None) --model-dir MODEL_DIR Model download directory (by setting XDG_CACHE_HOME environment variable), by default model downloaded to ~/.cache (default: /Users/cwq/.cache) --disable-model-switch Disable model switch in frontend (default: False)
06-09
这是一些可选参数,可以在命令行中使用来配置运行环境和模型选择等。下面是每个参数的解释: - -h, --help:显示帮助信息并退出。 - --host HOST:设置服务器主机地址。 - --port PORT:设置服务器端口号。 - --config-installer:打开配置页面,主要用于Windows安装程序(默认值为False)。 - --load-installer-config:从安装程序配置文件中加载所有命令参数(默认值为False)。 - --installer-config INSTALLER_CONFIG:Windows安装程序的配置文件路径(默认值为None)。 - --model {lama,ldm,zits,mat,fcf,sd1.5,cv2,manga,sd2,paint_by_example,instruct_pix2pix}:选择要使用的模型。 - --no-half:使用完整精度模型。如果生成的结果总是黑色或绿色,请使用此参数(仅适用于sd/paint_by_exmaple模型)(默认值为False)。 - --cpu-offload:将所有模型卸载到CPU上,大大减少vRAM的使用(仅适用于sd/paint_by_example模型)(默认值为False)。 - --disable-nsfw:禁用NSFW检查器(仅适用于sd/paint_by_example模型)(默认值为False)。 - --sd-cpu-textencoder:在CPU上运行稳定扩散文本编码器模型以节省GPU内存(默认值为False)。 - --local-files-only:仅使用本地文件,不连接到Hugging Face服务器(仅适用于sd/paint_by_example模型)(默认值为False)。 - --enable-xformers:启用xFormers优化。需要安装xformers软件包。请参见:https://github.com/facebookresearch/xformers(默认值为False)。 - --device {cuda,cpu,mps}:选择使用的设备(默认值为cuda)。 - --gui:将Lama Cleaner作为桌面应用程序启动(默认值为False)。 - --no-gui-auto-close:在GUI窗口关闭后防止后端自动关闭(默认值为False)。 - --gui-size GUI_SIZE GUI_SIZE:设置GUI窗口的大小(默认值为[1600,1000])。 - --input INPUT:如果输入为图像,则默认加载图像。如果输入为目录,则可以在文件管理器中浏览并选择图像(默认值为None)。 - --output-dir OUTPUT_DIR:自动将结果图像保存到输出目录,无需确认(默认值为None)。 - --model-dir MODEL_DIR:模型下载目录(通过设置XDG_CACHE_HOME环境变量),默认情况下模型下载到~/.cache(默认值为/Users/cwq/.cache)。 - --disable-model-switch:禁用前端的模型切换功能(默认值为False)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FriendshipT

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值