OCR-as-a-Service icon indicating copy to clipboard operation
OCR-as-a-Service copied to clipboard

Can't test the docker containers as is

Open MayStepanyan opened this issue 2 years ago β€’ 7 comments
trafficstars

Hi.

I run the command from README:

docker run --gpus all -p 3000:3000 ghcr.io/bentoml/ocr-as-a-service:gpu

and after pulling it throws an error:

FileNotFoundError: BentoML config file specified in ENV VAR not found: 'BENTOML_CONFIG=./config/default.yaml'

I've tried to create a dummy config with this content:

version: 1
api_server:
  workers: 4

which results in another error:

2023-09-05T07:20:23+0000 [ERROR] [cli] Failed to download https://layoutlm.blob.core.windows.net/dit/dit-fts/publaynet_dit-b_cascade.pth
Traceback (most recent call last):
  File "/usr/local/bin/bentoml", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/bentoml_cli/utils.py", line 334, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/bentoml_cli/utils.py", line 305, in wrapper
    return_value = func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/bentoml_cli/utils.py", line 262, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/bentoml_cli/env_manager.py", line 122, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/bentoml_cli/serve.py", line 218, in serve
    serve_http_production(
  File "/usr/local/lib/python3.9/site-packages/simple_di/__init__.py", line 139, in _
    return func(*_inject_args(bind.args), **_inject_kwargs(bind.kwargs))
  File "/usr/local/lib/python3.9/site-packages/bentoml/serve.py", line 266, in serve_http_production
    svc = load(bento_identifier, working_dir=working_dir)
  File "/usr/local/lib/python3.9/site-packages/bentoml/_internal/service/loader.py", line 328, in load
    svc = load_bento_dir(bento_path, standalone_load=standalone_load)
  File "/usr/local/lib/python3.9/site-packages/bentoml/_internal/service/loader.py", line 236, in load_bento_dir
    return _load_bento(bento, standalone_load)
  File "/usr/local/lib/python3.9/site-packages/bentoml/_internal/service/loader.py", line 246, in _load_bento
    svc = import_service(
  File "/usr/local/lib/python3.9/site-packages/simple_di/__init__.py", line 139, in _
    return func(*_inject_args(bind.args), **_inject_kwargs(bind.kwargs))
  File "/usr/local/lib/python3.9/site-packages/bentoml/_internal/service/loader.py", line 137, in import_service
    module = importlib.import_module(module_name, package=working_dir)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/bentoml/bento/src/service.py", line 12, in <module>
    from warmup import convert_pdf_to_images
  File "/home/bentoml/bento/src/warmup.py", line 121, in <module>
    predictor = dit.get_predictor(cfg)
  File "/home/bentoml/bento/src/dit/__init__.py", line 38, in get_predictor
    return DefaultPredictor(get_cfg(cfg))
  File "/usr/local/lib/python3.9/site-packages/detectron2/engine/defaults.py", line 288, in __init__
    checkpointer.load(cfg.MODEL.WEIGHTS)
  File "/usr/local/lib/python3.9/site-packages/detectron2/checkpoint/detection_checkpoint.py", line 61, in load
    path = self.path_manager.get_local_path(path)
  File "/usr/local/lib/python3.9/site-packages/iopath/common/file_io.py", line 1197, in get_local_path
    bret = handler._get_local_path(path, force=force, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/iopath/common/file_io.py", line 797, in _get_local_path
    cached = download(path, dirname, filename=filename)
  File "/usr/local/lib/python3.9/site-packages/iopath/common/download.py", line 58, in download
    tmp, _ = request.urlretrieve(url, filename=tmp, reporthook=hook(t))
  File "/usr/local/lib/python3.9/urllib/request.py", line 239, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/usr/local/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/local/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 409: Public access is not permitted on this storage account.

Same issues is with cpu docker image.

I suspect the config file should include some credentials I don't have access to. How can I fix this issue to test the service?

MayStepanyan avatar Sep 05 '23 07:09 MayStepanyan

Update: tried the install version too, throws the same exception with HTTP Error 409

MayStepanyan avatar Sep 05 '23 10:09 MayStepanyan

@jianshen92 can you help take a look with this?

aarnphm avatar Sep 11 '23 20:09 aarnphm

I'm running into the same issue. Any suggestions on how to get it working?

alejones avatar Oct 19 '23 21:10 alejones

@alejones yes, I fixed this.

Turns out publayanet link in dit/__init__.py/get_cfg(), line 26 is not working. We

  1. Found a new link and downloaded the weights locally under the name "publaynet_dit-b_cascade.pth" (we just added a suffix to the link as mentioned here)

  2. changed the mentioned line of code to cfg.MODEL.WEIGHTS = ("publaynet_dit-b_cascade.pth") to reuse the same file and not download it on every run again

  3. Mounted the weights file when running the script with docker

It works just fine.

MayStepanyan avatar Oct 24 '23 17:10 MayStepanyan

@alejones yes, I fixed this.

Turns out publayanet link in dit/__init__.py/get_cfg(), line 26 is not working. We

  1. Found a new link and downloaded the weights locally under the name "publaynet_dit-b_cascade.pth" (we just added a suffix to the link as mentioned here)

  2. changed the mentioned line of code to cfg.MODEL.WEIGHTS = ("publaynet_dit-b_cascade.pth")

  3. Mounted the weights file when running the script with docker

It works just fine.

Hey @MayStepanyan ! Thanks for checking it out! Would be very helpful to the team if you could raise a PR for this fix!

jianshen92 avatar Oct 24 '23 17:10 jianshen92

mark, I met the same problem

skytodmoon avatar Aug 06 '24 08:08 skytodmoon

I find a new effective model url: "https://huggingface.co/discus0434/publaynet-dit-base/resolve/main/publaynet_dit-b_cascade.pth"

skytodmoon avatar Aug 07 '24 00:08 skytodmoon