Comments (3)
Let's say the encoder of the original SAM on a 2080 Ti takes 235 ms and that of the EdgeSAM takes 5 ms and the decoder of both models takes 1 ms. The total execution times in everything mode are 235 + 1024 * 1 = 1259 ms
and 5 + 1024 * 1 = 1029 ms
for SAM and EdgeSAM respectively.
So, if VRAM is not your bottleneck, I would recommend using the original SAM instead.
from edgesam.
Since EdgeSAM follows the same encoder-decoder architecture as SAM, the everything mode will infer the decoder 32x32=1024 times, which is very inefficient. So I don't recommend doing that.
But if you really want to try it out, here is the script:
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator
sam = sam_model_registry["edge_sam"](checkpoint="weights/edge_sam_3x.pth")
sam = sam.to(device=device)
sam.eval()
mask_generator = SamAutomaticMaskGenerator(sam)
# TODO: read an image and convert it to numpy.ndarray
masks = mask_generator.generate(image)
from edgesam.
I don't want to manually set points or boxes, I want to directly segment all the objects in the graph
Hello, sssegmentation also supported EdgeSAM now, you can write the following codes to achieve this goal after installing sssegmentation,
import cv2
import torch
import numpy as np
import matplotlib.pyplot as plt
from ssseg.modules.models.segmentors.sam.visualization import showanns
from ssseg.modules.models.segmentors.edgesam import EdgeSAMAutomaticMaskGenerator
# read image
image = cv2.imread('images/dog.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# mask generator
mask_generator = EdgeSAMAutomaticMaskGenerator(use_default_edgesam=True, device='cuda')
# generate masks on an image
masks = mask_generator.generate(image)
# show all the masks overlayed on the image
plt.figure(figsize=(20, 20))
plt.imshow(image)
showanns(masks)
plt.axis('off')
plt.savefig('mask.png')
from edgesam.
Related Issues (19)
- Training Code HOT 1
- One MNN deployment of EdgeSAM may helps
- could you provide the train code? HOT 1
- License HOT 3
- X-AnyLabeling-EdgeSAM demo support HOT 1
- training code
- Query on ONNX Encoder Inference Time: Samsung A20 with Android 11
- Decoder CoreML running time problem HOT 2
- Finetuning
- Is it possible to export an onnx model with input size 1024*720?
- whole image HOT 1
- Segment Anything CPP Wrapper for macOS
- Request for NCNN Integration in EdgeSAM Project HOT 1
- 关于RPN Module HOT 1
- 模型无法下载下呀? HOT 1
- Grounded-Edge-SAM demo support HOT 1
- tensorrt&rknn&altas inference HOT 2
- Segmentation labeling tool ISAT has supported EdgeSAM. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edgesam.