Giter VIP home page Giter VIP logo

document-layout-analysis-app's People

Contributors

hpanwar08 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

document-layout-analysis-app's Issues

Error running flask-api: RuntimeError: [enforce fail at inline_container.cc:208] . file not found: /version

Downloaded model_final_trimmed.pth file from dropbox link in the repo, placed it in the backend/ folder.

When running docker-compose up --build following error pops up and the flask_api fails to load.

Loaded config: DLA_mask_rcnn_R_101_FPN_3x.yaml
Loaded model: model_final_trimmed.pth
Traceback (most recent call last):
  File "/app/bin/flask", line 8, in <module>
    sys.exit(main())
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 967, in main
    cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/app/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/app/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/app/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/app/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/app/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/app/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 848, in run_command
    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 305, in __init__
    self._load_unlocked()
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 330, in _load_unlocked
    self._app = rv = self.loader()
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "/app/lib/python3.8/site-packages/flask/cli.py", line 240, in locate_app
    __import__(module_name)
  File "/app/dla.py", line 3, in <module>
    app = create_app()
  File "/app/project/__init__.py", line 16, in create_app
    from project.api.dla_api import dla_blueprint
  File "/app/project/api/dla_api.py", line 5, in <module>
    from project.predictor import make_predictions
  File "/app/project/predictor.py", line 95, in <module>
    predictor = prepare_predictor()
  File "/app/project/predictor.py", line 38, in prepare_predictor
    predictor = VisualizationDemo(cfg)
  File "/app/project/d2predictor.py", line 36, in __init__
    self.predictor = DefaultPredictor(cfg)
  File "/app/lib/python3.8/site-packages/detectron2/engine/defaults.py", line 187, in __init__
    checkpointer.load(cfg.MODEL.WEIGHTS)
  File "/app/lib/python3.8/site-packages/fvcore/common/checkpoint.py", line 120, in load
    checkpoint = self._load_file(path)
  File "/app/lib/python3.8/site-packages/detectron2/checkpoint/detection_checkpoint.py", line 42, in _load_file
    loaded = super()._load_file(filename)  # load native pth checkpoint
  File "/app/lib/python3.8/site-packages/fvcore/common/checkpoint.py", line 216, in _load_file
    return torch.load(f, map_location=torch.device("cpu"))
  File "/app/lib/python3.8/site-packages/torch/serialization.py", line 586, in load
    with _open_zipfile_reader(f) as opened_zipfile:
  File "/app/lib/python3.8/site-packages/torch/serialization.py", line 246, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: [enforce fail at inline_container.cc:208] . file not found: /version

How can this be resolved?

Handle grayscale images in backend

The backend api currently throws a 500 error when a grayscale image is passed to /analyse-image-json endpoint, mentioning: image.shape[2] is out of index.

Updating the following code: https://github.com/hpanwar08/document-layout-analysis-app/blob/master/backend/project/api/dla_api.py#L22-L23 to

-    if image.shape[2] == 4:
+    if len(image.shape) == 2:  # grayscale image
+        image = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)
+    elif image.shape[2] == 4:
         image = cv2.cvtColor(image, cv2.COLOR_BGRA2BGR)

resolved the issue.

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.