最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Segment-geospatial error in sam.predict: NoneType object is not subscriptable - Stack Overflow

programmeradmin1浏览0评论

I am using the library segment-geospatial to try and segment some plants in a raster image I have.

image = '/content/drive/MyDrive/myimage.tiff'
sam = SamGeo(
    model_type="vit_h",
    automatic=False,
    sam_kwargs=None,
)

sam.set_image(image)

boxes = [
        [-51.2546, -22.1771, -51.2541, -22.1767],
        [-51.2538, -22.1764, -51.2535, -22.1761],
]

sam.predict(boxes=boxes, point_crs="EPSG:4326", output="mask.tif", dtype="uint8")

When I run sam.predict() I get the following error:


No valid pixel coordinates found.
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-72-a3b6cdcab301> in <cell line: 0>()
----> 1 sam.predict(boxes=boxes, point_crs="EPSG:4326", output="mask.tif", dtype="uint8")

/usr/local/lib/python3.11/dist-packages/samgeo/samgeo.py in predict(self, point_coords, point_labels, boxes, point_crs, mask_input, multimask_output, return_logits, output, index, mask_multiplier, dtype, return_results, **kwargs)
    615             coords = bbox_to_xy(self.source, boxes, point_crs)
    616             input_boxes = np.array(coords)
--> 617             if isinstance(coords[0], int):
    618                 input_boxes = input_boxes[None, :]
    619             else:

TypeError: 'NoneType' object is not subscriptable

I have already checked that the raster image crs format is correct and I already tried this code with the example they provide in the documentation and it worked fine, but when I try it with my raster it doesn't work. /

发布评论

评论列表(0)

  1. 暂无评论