Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"torch",
"torchvision",
"pycocotools>=2.0.2",
"fvcore==0.1.1.post20200623",
"iopath",
],
extras_require={
"ocr": [
Expand Down
9 changes: 6 additions & 3 deletions src/layoutparser/models/catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from fvcore.common.file_io import PathHandler, PathManager, HTTPURLHandler
from iopath.common.file_io import PathHandler, PathManager, HTTPURLHandler
from iopath.common.file_io import PathManager as PathManagerBase
# A trick learned from https://github.com/facebookresearch/detectron2/blob/65faeb4779e4c142484deeece18dc958c5c9ad18/detectron2/utils/file_io.py#L3

MODEL_CATALOG = {
'HJDataset': {
Expand Down Expand Up @@ -61,7 +63,7 @@ class LayoutParserHandler(PathHandler):
def _get_supported_prefixes(self):
return [self.PREFIX]

def _get_local_path(self, path):
def _get_local_path(self, path, **kwargs):
model_name = path[len(self.PREFIX):]
dataset_name, *model_name, data_type = model_name.split('/')

Expand All @@ -71,11 +73,12 @@ def _get_local_path(self, path):
model_url = CONFIG_CATALOG[dataset_name]['/'.join(model_name)]
else:
raise ValueError(f"Unknown data_type {data_type}")
return PathManager.get_local_path(model_url)
return PathManager.get_local_path(model_url, **kwargs)

def _open(self, path, mode="r", **kwargs):
return PathManager.open(self._get_local_path(path), mode, **kwargs)


PathManager = PathManagerBase()
PathManager.register_handler(DropboxHandler())
PathManager.register_handler(LayoutParserHandler())
4 changes: 1 addition & 3 deletions src/layoutparser/models/layoutmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from PIL import Image
import numpy as np
import torch
from fvcore.common.file_io import PathManager

# TODO: Update to iopath in the next major release

from .catalog import PathManager
from ..elements import *

__all__ = ["Detectron2LayoutModel"]
Expand Down