Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
---
|
4 |
+
|
5 |
+
## Fast state_dict loading for local uniform pruning SlimSAM-50 model:
|
6 |
+
|
7 |
+
``` python
|
8 |
+
model = SamModel.from_pretrained("Zigeng/SlimSAM-uniform-50").to("cuda")
|
9 |
+
processor = SamProcessor.from_pretrained("Zigeng/SlimSAM-uniform-50")
|
10 |
+
|
11 |
+
img_url = "https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png"
|
12 |
+
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert("RGB")
|
13 |
+
input_points = [[[450, 600]]] # 2D localization of a window
|
14 |
+
inputs = processor(raw_image, input_points=input_points, return_tensors="pt").to("cuda")
|
15 |
+
outputs = model(**inputs)
|
16 |
+
masks = processor.image_processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"].cpu(), inputs["reshaped_input_sizes"].cpu())
|
17 |
+
scores = outputs.iou_scores
|
18 |
+
```
|