开始使用免费开始使用

图像背景移除

在本练习中,您将继续使用之前的 flickr 数据集,该数据集包含 30,000 张图像及其对应的字幕。现在,您将移除图像背景。

Photo of 2 people, 1 is playing the guitar

示例图像(image)和 pipeline 模块(pipeline)已加载。

本练习是课程的一部分

使用 Hugging Face 的多模态模型

查看课程

练习说明

  • 使用 briaai/RMBG-1.4 预训练模型并启用 trust_remote_code,加载 image-segmentation pipeline。
  • 使用该 pipeline 修改输入的 image

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Load the image-segmentation pipeline
pipe = ____

# Use the pipeline to predict the class of the sample image
outputs = ____

plt.imshow(outputs)
plt.show()
编辑并运行代码