開始使用免費開始

移除影像背景

在這個練習中,你會使用與前面相同的 flickr 資料集,包含 30,000 張影像與相對應的標題。現在你要把影像的背景移除。

Photo of 2 people, 1 is playing the guitar

範例影像(image)與 pipeline 模組(pipeline)都已載入。

本練習屬於課程

使用 Hugging Face 的多模態模型

檢視課程

練習說明

  • 載入 image-segmentation pipeline,使用 briaai/RMBG-1.4 預訓練模型,並啟用 trust_remote_code
  • 使用該 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()
編輯並執行程式碼