Internal Server Error
rastarr opened this issue · 7 comments
Thanks for the repo
I've built the docker container and running with "{"data":"success"}"
I went to test with your supplied 'Example Base64 Image' and get an 'Internal Server Error'
Any ideas?
Logs are as follows-
INFO: Will watch for changes in these directories: ['/app']
INFO: Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO: Started reloader process [10] using WatchFiles
2023-04-10 07:53:29.440332: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
INFO: Started server process [12]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 172.19.0.1:65494 - "GET / HTTP/1.1" 200 OK
INFO: 172.19.0.1:65494 - "GET /favicon.ico HTTP/1.1" 404 Not Found
INFO: 172.19.0.1:55754 - "POST /ocr HTTP/1.1" 403 Forbidden
INFO: 172.19.0.1:61012 - "POST /ocr HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/conda/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call
return await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/fastapi/applications.py", line 276, in call
await super().call(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in call
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/opt/conda/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call
raise e
File "/opt/conda/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/opt/conda/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
raw_response = await run_endpoint_function(
File "/opt/conda/lib/python3.10/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
return await dependant.call(**values)
File "/app/ocr/router.py", line 21, in process
result = process_image_with_deep_learning_model(processed_image)
File "/app/ocr/utils.py", line 20, in process_image_with_deep_learning_model
processor = get_processor()
File "/app/config.py", line 22, in get_processor
return TrOCRProcessor.from_pretrained("/app/trocr-small-printed")
File "/opt/conda/lib/python3.10/site-packages/transformers/processing_utils.py", line 182, in from_pretrained
args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/transformers/processing_utils.py", line 226, in _get_arguments_from_pretrained
args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
File "/opt/conda/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 635, in from_pretrained
tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]
File "/opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 598, in getitem
raise KeyError(key)
KeyError: <class 'transformers.models.vision_encoder_decoder.configuration_vision_encoder_decoder.VisionEncoderDecoderConfig'>
INFO: 172.19.0.1:56370 - "POST /ocr HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/conda/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call
return await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/fastapi/applications.py", line 276, in call
await super().call(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in call
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/opt/conda/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call
raise e
File "/opt/conda/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/opt/conda/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
raw_response = await run_endpoint_function(
File "/opt/conda/lib/python3.10/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
return await dependant.call(**values)
File "/app/ocr/router.py", line 21, in process
result = process_image_with_deep_learning_model(processed_image)
File "/app/ocr/utils.py", line 20, in process_image_with_deep_learning_model
processor = get_processor()
File "/app/config.py", line 22, in get_processor
return TrOCRProcessor.from_pretrained("/app/trocr-small-printed")
File "/opt/conda/lib/python3.10/site-packages/transformers/processing_utils.py", line 182, in from_pretrained
args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/transformers/processing_utils.py", line 226, in _get_arguments_from_pretrained
args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, *kwargs))
File "/opt/conda/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 635, in from_pretrained
tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]
File "/opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 598, in getitem
raise KeyError(key)
KeyError: <class 'transformers.models.vision_encoder_decoder.configuration_vision_encoder_decoder.VisionEncoderDecoderConfig'>
Requirement already satisfied: fastapi in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 1)) (0.95.0)
Requirement already satisfied: uvicorn[standard] in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 2)) (0.21.1)
Requirement already satisfied: redis in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 3)) (4.5.4)
Requirement already satisfied: celery in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 4)) (5.2.7)
Requirement already satisfied: httpx in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 5)) (0.23.3)
Requirement already satisfied: pytest in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 6)) (7.3.0)
Requirement already satisfied: pydantic in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 9)) (1.10.7)
Requirement already satisfied: opencv-python-headless in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 11)) (4.7.0.72)
Requirement already satisfied: sentencepiece in /opt/conda/lib/python3.10/site-packages (from -r /usr/local/requirements.txt (line 12)) (0.1.97)
Requirement already satisfied: starlette<0.27.0,>=0.26.1 in /opt/conda/lib/python3.10/site-packages (from fastapi->-r /usr/local/requirements.txt (line 1)) (0.26.1)
Requirement already satisfied: click>=7.0 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (8.1.3)
Requirement already satisfied: h11>=0.8 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (0.14.0)
Requirement already satisfied: websockets>=10.4 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (11.0.1)
Requirement already satisfied: uvloop!=0.15.0,!=0.15.1,>=0.14.0 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (0.17.0)
Requirement already satisfied: watchfiles>=0.13 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (0.19.0)
Requirement already satisfied: pyyaml>=5.1 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (6.0)
Requirement already satisfied: python-dotenv>=0.13 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (1.0.0)
Requirement already satisfied: httptools>=0.5.0 in /opt/conda/lib/python3.10/site-packages (from uvicorn[standard]->-r /usr/local/requirements.txt (line 2)) (0.5.0)
Requirement already satisfied: async-timeout>=4.0.2 in /opt/conda/lib/python3.10/site-packages (from redis->-r /usr/local/requirements.txt (line 3)) (4.0.2)
Requirement already satisfied: kombu<6.0,>=5.2.3 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (5.2.4)
Requirement already satisfied: billiard<4.0,>=3.6.4.0 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (3.6.4.0)
Requirement already satisfied: click-repl>=0.2.0 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (0.2.0)
Requirement already satisfied: pytz>=2021.3 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (2023.3)
Requirement already satisfied: click-didyoumean>=0.0.3 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (0.3.0)
Requirement already satisfied: click-plugins>=1.1.1 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (1.1.1)
Requirement already satisfied: vine<6.0,>=5.0.0 in /opt/conda/lib/python3.10/site-packages (from celery->-r /usr/local/requirements.txt (line 4)) (5.0.0)
Requirement already satisfied: sniffio in /opt/conda/lib/python3.10/site-packages (from httpx->-r /usr/local/requirements.txt (line 5)) (1.3.0)
Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in /opt/conda/lib/python3.10/site-packages (from httpx->-r /usr/local/requirements.txt (line 5)) (1.5.0)
Requirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx->-r /usr/local/requirements.txt (line 5)) (2022.12.7)
Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in /opt/conda/lib/python3.10/site-packages (from httpx->-r /usr/local/requirements.txt (line 5)) (0.16.3)
Requirement already satisfied: packaging in /opt/conda/lib/python3.10/site-packages (from pytest->-r /usr/local/requirements.txt (line 6)) (23.0)
Requirement already satisfied: iniconfig in /opt/conda/lib/python3.10/site-packages (from pytest->-r /usr/local/requirements.txt (line 6)) (2.0.0)
Requirement already satisfied: tomli>=1.0.0 in /opt/conda/lib/python3.10/site-packages (from pytest->-r /usr/local/requirements.txt (line 6)) (2.0.1)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /opt/conda/lib/python3.10/site-packages (from pytest->-r /usr/local/requirements.txt (line 6)) (1.1.1)
Requirement already satisfied: pluggy<2.0,>=0.12 in /opt/conda/lib/python3.10/site-packages (from pytest->-r /usr/local/requirements.txt (line 6)) (1.0.0)
Requirement already satisfied: h2<5,>=3 in /opt/conda/lib/python3.10/site-packages (from httpx->-r /usr/local/requirements.txt (line 5)) (4.1.0)
Requirement already satisfied: socksio==1. in /opt/conda/lib/python3.10/site-packages (from httpx->-r /usr/local/requirements.txt (line 5)) (1.0.0)
Requirement already satisfied: typing-extensions>=4.2.0 in /opt/conda/lib/python3.10/site-packages (from pydantic->-r /usr/local/requirements.txt (line 9)) (4.5.0)
Requirement already satisfied: numpy>=1.19.3 in /opt/conda/lib/python3.10/site-packages (from opencv-python-headless->-r /usr/local/requirements.txt (line 11)) (1.22.3)
Requirement already satisfied: six in /opt/conda/lib/python3.10/site-packages (from click-repl>=0.2.0->celery->-r /usr/local/requirements.txt (line 4)) (1.16.0)
Requirement already satisfied: prompt-toolkit in /opt/conda/lib/python3.10/site-packages (from click-repl>=0.2.0->celery->-r /usr/local/requirements.txt (line 4)) (3.0.38)
Requirement already satisfied: hyperframe<7,>=6.0 in /opt/conda/lib/python3.10/site-packages (from h2<5,>=3->httpx->-r /usr/local/requirements.txt (line 5)) (6.0.1)
Requirement already satisfied: hpack<5,>=4.0 in /opt/conda/lib/python3.10/site-packages (from h2<5,>=3->httpx->-r /usr/local/requirements.txt (line 5)) (4.0.0)
Requirement already satisfied: anyio<5.0,>=3.0 in /opt/conda/lib/python3.10/site-packages (from httpcore<0.17.0,>=0.15.0->httpx->-r /usr/local/requirements.txt (line 5)) (3.6.2)
Requirement already satisfied: amqp<6.0.0,>=5.0.9 in /opt/conda/lib/python3.10/site-packages (from kombu<6.0,>=5.2.3->celery->-r /usr/local/requirements.txt (line 4)) (5.1.1)
Requirement already satisfied: idna in /opt/conda/lib/python3.10/site-packages (from rfc3986[idna2008]<2,>=1.3->httpx->-r /usr/local/requirements.txt (line 5)) (3.4)
Requirement already satisfied: wcwidth in /opt/conda/lib/python3.10/site-packages (from prompt-toolkit->click-repl>=0.2.0->celery->-r /usr/local/requirements.txt (line 4)) (0.2.6)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
INFO: Will watch for changes in these directories: ['/app']
INFO: Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO: Started reloader process [10] using WatchFiles
2023-04-10 08:02:57.991017: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
INFO: Started server process [12]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: 172.19.0.1:55734 - "POST /ocr HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/conda/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call
return await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/fastapi/applications.py", line 276, in call
await super().call(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in call
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/opt/conda/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/opt/conda/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call
raise e
File "/opt/conda/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/opt/conda/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/opt/conda/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
raw_response = await run_endpoint_function(
File "/opt/conda/lib/python3.10/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
return await dependant.call(**values)
File "/app/ocr/router.py", line 21, in process
result = process_image_with_deep_learning_model(processed_image)
File "/app/ocr/utils.py", line 20, in process_image_with_deep_learning_model
processor = get_processor()
File "/app/config.py", line 22, in get_processor
return TrOCRProcessor.from_pretrained("/app/trocr-small-printed")
File "/opt/conda/lib/python3.10/site-packages/transformers/processing_utils.py", line 182, in from_pretrained
args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/transformers/processing_utils.py", line 226, in _get_arguments_from_pretrained
args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
File "/opt/conda/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 635, in from_pretrained
tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]
File "/opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 598, in getitem
raise KeyError(key)
KeyError: <class 'transformers.models.vision_encoder_decoder.configuration_vision_encoder_decoder.VisionEncoderDecoderConfig'>
At first, Are you in main
branch or fine-tune-with-new-data
if are you in main
branch did you clone transfer model?
https://github.com/moaminsharifi/ocr-api/tree/fine-tune-with-new-data#go-to--api-directory-and-clone-model
if your input is just a number I realy suggest to use fine-tune-with-new-data
, that branch specifically trained for numberic captcha and is faster.
OK, I'll have a look
Does your repo then, have the ability to train on a captcha type like Kcaptcha then?
or is it restricted to a certain type?
If you have enough data we can train for it. for now main
work as ocr for any type.
fine-tune-with-new-data
works only on numberic captcha.
How do I go about 'training' the model with data?
at first we need 500-1000 labled data and then we can train or fintune a model for our self.
Is this training something I can do?
I can get images, yes.
If you collect images and label them I can train a model for you.
You can contact me in telegram with @moaminsharifi id.