@@ -39,12 +39,14 @@ The original code can be found [here](https://github.com/facebookresearch/segmen
|
||||
Below is an example on how to run mask generation given an image and a 2D point:
|
||||
|
||||
```python
|
||||
import torch
|
||||
from PIL import Image
|
||||
import requests
|
||||
from transformers import SamModelForMaskedGeneration, SamProcessor
|
||||
from transformers import SamModel, SamProcessor
|
||||
|
||||
model = SamModelForMaskedGeneration.from_pretrained("facebook/sam-vit-huge")
|
||||
processsor = SamProcessor.from_pretrained("facebook/sam-vit-huge")
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
model = SamModel.from_pretrained("facebook/sam-vit-huge").to(device)
|
||||
processor = SamProcessor.from_pretrained("facebook/sam-vit-huge")
|
||||
|
||||
img_url = "https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png"
|
||||
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert("RGB")
|
||||
@@ -93,4 +95,4 @@ Resources:
|
||||
## SamModel
|
||||
|
||||
[[autodoc]] SamModel
|
||||
- forward
|
||||
- forward
|
||||
|
||||
Reference in New Issue
Block a user