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

Can't run cellsparse in QuPath because of Pillow (or base64 or io) #6

Open
tpecot opened this issue Nov 29, 2023 · 3 comments
Open

Comments

@tpecot
Copy link

tpecot commented Nov 29, 2023

Hi,

I've been trying to install cellsparse tu run it within QuPath. I'm running a Windows PC and I use QuPath 0.4.3 (I also tested QuPath 0.4.4, got the same problem) and qupath-extension-cellsparse-0.2.0. I was able to install the SAM extension running on my GPU without any problem. I tried to install both the GPU version and the CPU version (I thought it might come from the python version, 3.10 for installing GPU version for Windows, 3.11 for CPU) but got the same problem, i.e. when I run cellsparse extension to train either with Cellpose, ELEPHANT or Stardist, I get the following error:
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\fastapi\applications.py", line 276, in call
await super().call(scope, receive, send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\middleware\errors.py", line 184, in call
raise exc
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\middleware\errors.py", line 162, in call
await self.app(scope, receive, _send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\middleware\exceptions.py", line 79, in call
raise exc
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\middleware\exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call
raise e
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\routing.py", line 718, in call
await route.handle(scope, receive, send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\routing.py", line 276, in handle
await self.app(scope, receive, send)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\starlette\routing.py", line 66, in app
response = await func(request)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\fastapi\routing.py", line 237, in app
raw_response = await run_endpoint_function(
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\fastapi\routing.py", line 163, in run_endpoint_function
return await dependant.call(**values)
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\cellsparse_api\main.py", line 144, in stardist
return run(
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\cellsparse_api\main.py", line 42, in run
img = normalize(decode_image(b64img), 0, 100, axis=(0, 1))
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\cellsparse_api\main.py", line 30, in decode_image
return np.array(Image.open(io.BytesIO(base64.b64decode(b64data))))
File "C:\Users\tpecot\Anaconda3\envs\cellsparse-api\lib\site-packages\PIL\Image.py", line 3305, in open
raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000001B2AF9BEE30>

It seems that it comes from PIL or base64 or io, I tried to change Pillow package version, but got the same error. Any idea?

Thanks a lot!!!

@tpecot
Copy link
Author

tpecot commented Nov 30, 2023

Just to clarify, it looks similar to a previous issue where the problem was that it was applied to multi-channel image. I have this problem when using cellsparse on a 8 bits grayscale image.

Thanks again for your help!

@ksugar
Copy link
Owner

ksugar commented Nov 30, 2023

Hi @tpecot, thank you for reporting the issue. I will investigate it.
How about the size of the image? It would be helpful if you could share the image metadata found in QuPath.
image

@tpecot
Copy link
Author

tpecot commented Nov 30, 2023

Thanks for your reply @ksugar ! Actually, I tried several images and always got the same problem, here is one example of metadata:
example
After your message, I used an image from the Broad Bioimage Benchmark Collection with these metadata:
exampleBI
... and it works. I must say I don't understand why it doesn't work for the other images but it's reassuring, I'll make some new tests but I should be able to find out what's going on. Sorry to have bothered you because of that and thanks again!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants