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

範例影像(image)與 pipeline 模組(pipeline)都已載入。
本練習屬於課程
使用 Hugging Face 的多模態模型
練習說明
- 載入
image-segmentationpipeline,使用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()