"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "ba0d50f2148f0db0e04a80cddb1f57ce0c91c182"
Unverified Commit 4cfe328b authored by fxmarty's avatar fxmarty Committed by GitHub
Browse files

Fix SAM example in documentation (#22887)

fix sam example
parent cb47293e
......@@ -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
\ No newline at end of file
- forward
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment