Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam.generate(): Error with uploaded images #248

Closed
aloboa opened this issue Feb 19, 2024 · 2 comments
Closed

sam.generate(): Error with uploaded images #248

aloboa opened this issue Feb 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@aloboa
Copy link

aloboa commented Feb 19, 2024

Environment Information

  • samgeo version: (colab)
  • Python version: 3 (colab)
  • Operating System: colab

Description

Tried to run automatic_mask_generator.ipynb with a tiny (123 224 3) GTiff image uploaded to colab.
sam.generate produces an error.

What I Did

image = '/content/mini.tif'
sam.generate(image, output="masks.tif", foreground=True, unique=True)
---------------------------------------------------------------------------

error                                     Traceback (most recent call last)

[<ipython-input-44-625ba53ba81a>](https://localhost:8080/#) in <cell line: 1>()
----> 1 sam.generate(image, output="masks.tif", foreground=True, unique=True)

[/usr/local/lib/python3.10/dist-packages/samgeo/samgeo.py](https://localhost:8080/#) in generate(self, source, output, foreground, batch, erosion_kernel, mask_multiplier, unique, **kwargs)
    197 
    198             image = cv2.imread(source)
--> 199             image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    200         elif isinstance(source, np.ndarray):
    201             image = source

error: OpenCV(4.8.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

test image: https://www.dropbox.com/scl/fi/8f8c6j9b7h6vk0b62qmx1/mini.tif?rlkey=swfjtay3s5rzw2k0chizgdcm7&dl=0

@aloboa aloboa added the bug Something isn't working label Feb 19, 2024
@giswqs
Copy link
Member

giswqs commented Feb 19, 2024

It only supports 8-bit integer type. Your image is floating type.

@giswqs giswqs closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
@aloboa
Copy link
Author

aloboa commented Feb 19, 2024

It only supports 8-bit integer type. Your image is floating type.

I confirm it works with the same image as INT1U. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants