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

PIL.UnidentifiedImageError: cannot identify image file #8

Open
sanduluca opened this issue Dec 18, 2023 · 0 comments
Open

PIL.UnidentifiedImageError: cannot identify image file #8

sanduluca opened this issue Dec 18, 2023 · 0 comments

Comments

@sanduluca
Copy link

2023-12-18 14:55:38 INFO:     Started server process [8]
2023-12-18 14:55:38 INFO:     Waiting for application startup.
2023-12-18 14:55:38 INFO:     Application startup complete.
2023-12-18 14:55:38 INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2023-12-18 14:55:42 Loading weights from checkpoint (models/text_detector/craft_mlt_25k.pth)
2023-12-18 14:55:42 Loading weights from checkpoint (models/text_recognizer/TPS-ResNet-BiLSTM-Attn-case-sensitive.pth)
2023-12-18 14:55:42 INFO:     192.168.65.1:31139 - "POST /ocr/predict HTTP/1.1" 500 Internal Server Error
2023-12-18 14:55:42 ERROR:    Exception in ASGI application
2023-12-18 14:55:42 Traceback (most recent call last):
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 420, in run_asgi
2023-12-18 14:55:42     self.scope, self.receive, self.send
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
2023-12-18 14:55:42     return await self.app(scope, receive, send)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 208, in __call__
2023-12-18 14:55:42     await super().__call__(scope, receive, send)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/applications.py", line 112, in __call__
2023-12-18 14:55:42     await self.middleware_stack(scope, receive, send)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__
2023-12-18 14:55:42     raise exc from None
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__
2023-12-18 14:55:42     await self.app(scope, receive, _send)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__
2023-12-18 14:55:42     raise exc from None
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__
2023-12-18 14:55:42     await self.app(scope, receive, sender)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 580, in __call__
2023-12-18 14:55:42     await route.handle(scope, receive, send)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 241, in handle
2023-12-18 14:55:42     await self.app(scope, receive, send)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 52, in app
2023-12-18 14:55:42     response = await func(request)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 227, in app
2023-12-18 14:55:42     dependant=dependant, values=values, is_coroutine=is_coroutine
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 161, in run_endpoint_function
2023-12-18 14:55:42     return await run_in_threadpool(dependant.call, **values)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
2023-12-18 14:55:42     return await loop.run_in_executor(None, func, *args)
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
2023-12-18 14:55:42     result = self.fn(*self.args, **self.kwargs)
2023-12-18 14:55:42   File "./main.py", line 39, in predict
2023-12-18 14:55:42     image = Image.open(io.BytesIO(img_bytes))
2023-12-18 14:55:42   File "/usr/local/lib/python3.7/site-packages/PIL/Image.py", line 3298, in open
2023-12-18 14:55:42     raise UnidentifiedImageError(msg)
2023-12-18 14:55:42 PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x40c3a58e30>
Curl command
curl --location 'http://localhost:8000/ocr/predict' \
--header 'Content-Type: application/json' \
--data '{
  "image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD"
}'
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

1 participant