INFO: 127.0.0.1:65113 - "POST /predict/image HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/protocols/http/h11_impl.py", line 394, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
return await self.app(scope, receive, send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/middleware/debug.py", line 81, in __call__
raise exc from None
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/uvicorn/middleware/debug.py", line 78, in __call__
await self.app(scope, receive, inner_send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/fastapi/applications.py", line 201, in __call__
await super().__call__(scope, receive, send) # pragma: no cover
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/applications.py", line 111, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/routing.py", line 566, in __call__
await route.handle(scope, receive, send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/routing.py", line 227, in handle
await self.app(scope, receive, send)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/starlette/routing.py", line 41, in app
response = await func(request)
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/fastapi/routing.py", line 202, in app
dependant=dependant, values=values, is_coroutine=is_coroutine
File "/Users/tuanvc/identity-card/lib/python3.6/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
return await dependant.call(**values)
File "server.py", line 27, in predict_api
prediction = predict(image)
File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/serve_model.py", line 23, in predict
result = model.predict(img)
File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/merged_model.py", line 94, in predict
self.text_recognition(cropped_image)
File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/merged_model.py", line 78, in text_recognition
result = self.text_recognition_model.predict_on_batch(np.array(list_ans))
File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/recognition.py", line 63, in predict_on_batch
return self.detector.batch_predict(batch_images)
File "/Users/tuanvc/Projects/extract-information-from-identity-card/complete/predictor.py", line 58, in batch_predict
sent = translate(batch, self.model).tolist()
AttributeError: 'tuple' object has no attribute 'tolist'
(array([
[ 1, 139, 2, 2, 2],
[ 1, 194, 197, 2, 98],
[ 1, 143, 120, 2, 2],
[ 1, 145, 137, 2, 2],
[ 1, 145, 28, 98, 2],
[ 1, 77, 114, 2, 2],
[ 1, 43, 76, 86, 2]]),
array([0.58601838, 0.83988384, 0.89621916, 0.92887259, 0.9296508 ,0.71749118, 0.93631878]))
Bạn có thể gợi ý cho mình về kết quả của translate(batch, self.model) để mình fix lỗi này được không?
Cảm ơn bạn rất nhiều!