当前位置:首页 > python > 正文内容

python 实现快速扣背景图功能

zhangsir3年前 (2023-01-06)python276

一,实现快速扣背景图需要rembg这个三方库

#引入rembg库
from rembg import remove
#素材
input_path = 'input.jpg'
#效果
output_path = 'output.jpg'
#打开素材图
with open(input_path, 'rb') as i:
    #打开效果图
    with open(output_path, 'wb') as o:
        #读取素材图数据
        input = i.read()
        #进行抠图处理
        output = remove(input)
        #写入数据
        o.write(output)


zhangsir版权c2防采集https://mianka.xyz

扫描二维码推送至手机访问。

版权声明:本文由zhangsir or zhangmaam发布,如需转载请注明出处。

本文链接:https://www.mianka.xyz/post/91.html

标签: python
分享给朋友:

“python 实现快速扣背景图功能” 的相关文章

python scrapy库安装

(1)安装pip install -i https://pypi.tuna.tsinghua.edu.cn/simple scrapy (2) 报错1: building 'twisted.test.raiser' extension...

Selenium添加Cookie来实现自动登录

Selenium添加Cookie来实现自动登录第一步获取你登录的cookie,以csdn为例from selenium import webdriver driver = webdriver.Chrome() driver.get('...

解决Django的request.POST获取不到请求参数的问题

这个是Django自身的问题:只要在请求头的添加"content-type":'application/x-www-form-urlencoded'就行。...

python selenium find_element_by_xpath 方法已经被弃用的解决办法

背景:在使用最新3.10.4Python版本时候,用selenium进行xpath定位元素,编译器提示:DeprecationWarning:find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value...

python 爬虫 报错:UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0x8b in position”解决方案

发现报错“UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1:invalid start byte”,方法一:根据报错提示,错误原因有一条是这样的:“'Accept-Encodi...

python 使用PIL库进行验证码清晰处理

python 使用PIL库进行验证码清晰处理from PIL import Image import sys import os sys.setrecursionlimit(1000000) pixel_list = []...