ap-kai / segment-anything-pd Goto Github PK
View Code? Open in Web Editor NEWSegment Anything With PaddlePaddle
License: Apache License 2.0
Segment Anything With PaddlePaddle
License: Apache License 2.0
要求提供ViT-H SAM 模型国内链接:
默认值
或vit_h
:ViT-H SAM 模型。vit_l
:ViT-L SAM 模型。vit_b
:ViT-B SAM模型。import sys
sys.path.append("..")
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor
sam_checkpoint = "../models/sam_vit_b_01ec64.pdparams"
model_type = "vit_b"
sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
# device = "cuda"
sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
# predictor = SamPredictor(sam)
mask_generator = SamAutomaticMaskGenerator(sam)
mask = mask_generator.generate(image)
'ValueError Traceback (most recent call last)
/tmp/ipykernel_1213/1982803247.py in
----> 1 mask = mask_generator.generate(image)
in generate(self, image)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py in _decorate_function(func, *args, **kwargs)
373 def _decorate_function(func, *args, **kwargs):
374 with self:
--> 375 return func(*args, **kwargs)
376
377 @decorator.decorator
~/segment-anything-pd/segment_anything/automatic_mask_generator.py in generate(self, image)
183
184 # Generate masks
--> 185 mask_data = self._generate_masks(image)
186
187 # Filter small disconnected regions and holes in masks
~/segment-anything-pd/segment_anything/automatic_mask_generator.py in _generate_masks(self, image)
226 data = MaskData()
227 for crop_box, layer_idx in zip(crop_boxes, layer_idxs):
--> 228 crop_data = self._process_crop(image, crop_box, layer_idx, orig_size)
229 data.cat(crop_data)
230
~/segment-anything-pd/segment_anything/automatic_mask_generator.py in _process_crop(self, image, crop_box, crop_layer_idx, orig_size)
273 boxes=data["boxes"].astype(paddle.float32),
274 scores=data["iou_preds"],
--> 275 categories=paddle.zeros(len(data["boxes"])), # categories
276 iou_threshold=self.box_nms_thresh,
277 )
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/tensor/creation.py in zeros(shape, dtype, name)
727 if dtype is None:
728 dtype = 'float32'
--> 729 return fill_constant(value=0.0, shape=shape, dtype=dtype, name=name)
730
731
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/tensor.py in fill_constant(shape, dtype, value, force_cpu, out, name)
793
794 if out is None:
--> 795 out = _C_ops.full(shape, float(value), dtype, place)
796 out.stop_gradient = True
797 return out
ValueError: (InvalidArgument) full(): argument (position 1) must be list or Tensor, but got int (at /paddle/paddle/fluid/pybind/eager_utils.cc:1404)'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.