Giter Site home page Giter Site logo

Comments (4)

verarong avatar verarong commented on July 20, 2024

文档中能否大概写一下部署到docker中的步骤?

直接docker-compose up就行啦

from invoice_ocr.

GavinHome avatar GavinHome commented on July 20, 2024

但是我这样运行后,一直有个错误:

image

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/uvicorn/protocols/http/httptools_impl.py", line 385, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/usr/local/lib/python3.6/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/fastapi/applications.py", line 151, in call
await super().call(scope, receive, send) # pragma: no cover
File "/usr/local/lib/python3.6/site-packages/starlette/applications.py", line 102, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc from None
File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 82, in call
raise exc from None
File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 550, in call
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 227, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 41, in app
response = await func(request)
File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 197, in app
dependant=dependant, values=values, is_coroutine=is_coroutine
File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 150, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/usr/local/lib/python3.6/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "./app/main.py", line 19, in predict
predicts = engine.predict(item)
File "./app/handler.py", line 169, in predict
ocr_score, box, score
, angle = self.img_2_text(self.read_img(img_path, img_base64))
File "./app/handler.py", line 116, in img_2_text
img, angle = self.img_rotation(img)
File "./app/handler.py", line 74, in img_rotation
angle = int(np.argmax(self.angle.predict(utils.read_for_rotation(img))[0]))
File "./app/serving_client.py", line 29, in predict
response = stub.Predict(request, self.timeout)
File "/usr/local/lib/python3.6/site-packages/grpc/_channel.py", line 946, in call
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.6/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1623245352.980858695","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3008,"referenced_errors":[{"created":"@1623245264.504494750","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14}]}"

在swagger中发起的请求如下:
curl -X 'POST' \ 'http://localhost:8000/predict' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "RequestId": "abc123", "InvoiceType": "common", "ImageUrl": "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=407903296,3852081406&fm=11&gp=0.jpg" }'

我对InvoiceType理解不是很透彻,大概读了一下源码,不知道怎么解决这个问题,还请赐教,图中是我在docker中部署的情况:
image

from invoice_ocr.

verarong avatar verarong commented on July 20, 2024

但是我这样运行后,一直有个错误:

image

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/uvicorn/protocols/http/httptools_impl.py", line 385, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/usr/local/lib/python3.6/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in call
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/fastapi/applications.py", line 151, in call
await super().call(scope, receive, send) # pragma: no cover
File "/usr/local/lib/python3.6/site-packages/starlette/applications.py", line 102, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc from None
File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, send) File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 82, in call raise exc from None File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 71, in call await self.app(scope, receive, sender) File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 550, in call await route.handle(scope, receive, send) File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 227, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 41, in app response = await func(request) File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 197, in app dependant=dependant, values=values, is_coroutine=is_coroutine File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 150, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) File "/usr/local/lib/python3.6/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool return await loop.run_in_executor(None, func, *args) File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "./app/main.py", line 19, in predict predicts = engine.predict(item) File "./app/handler.py", line 169, in predict ocr_score, box, score, angle = self.img_2_text(self.read_img(img_path, img_base64))
File "./app/handler.py", line 116, in img_2_text
img, angle = self.img_rotation(img)
File "./app/handler.py", line 74, in img_rotation
angle = int(np.argmax(self.angle.predict(utils.read_for_rotation(img))[0]))
File "./app/serving_client.py", line 29, in predict
response = stub.Predict(request, self.timeout)
File "/usr/local/lib/python3.6/site-packages/grpc/_channel.py", line 946, in call
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.6/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1623245352.980858695","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3008,"referenced_errors":[{"created":"@1623245264.504494750","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14}]}"

在swagger中发起的请求如下:
curl -X 'POST' \ 'http://localhost:8000/predict' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "RequestId": "abc123", "InvoiceType": "common", "ImageUrl": "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=407903296,3852081406&fm=11&gp=0.jpg" }'

我对InvoiceType理解不是很透彻,大概读了一下源码,不知道怎么解决这个问题,还请赐教,图中是我在docker中部署的情况:
image

看日志不是InvoiceType的问题(https://github.com/verarong/invoice_ocr/blob/main/app/extractor/invoice_config.py里面有invoicetype和配置)
看日志问题出在fastapi没有练到tfserving,一种方法是再docker-compose里面加环境变量,一种方法是再config里面直接用映射出来的host和port

from invoice_ocr.

gopher-max avatar gopher-max commented on July 20, 2024

@verarong

docker自定义了一个网络wifi,并将4个模型加入到该网络了,还是会出现无法通信的问题。

image

image

image

image

from invoice_ocr.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.