Skip to content

Commit 64ffecb

Browse files
author
publicmatt
committed
fix: redirect catalog URLs from dropbox to huggingface
dropbox links in MODEL_CATALOG and CONFIG_CATALOG now return HTML. that breaks torch.load on every checkpoint fetch. ports upstream PR Layout-Parser#226 (open, unmerged). adds HuggingfaceHandler so iopath knows the new prefix. released as 0.3.5; downstream pins are relaxed in lockstep.
1 parent 89aca03 commit 64ffecb

4 files changed

Lines changed: 39 additions & 28 deletions

File tree

src/layoutparser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.3.4"
15+
__version__ = "0.3.5"
1616

1717
import sys
1818

src/layoutparser/models/base_catalog.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def _get_supported_prefixes(self):
2929
def _isfile(self, path):
3030
return path in self.cache_map
3131

32+
class HuggingfaceHandler(HTTPURLHandler):
33+
"""
34+
Supports download and file check for Huggingface links
35+
"""
36+
37+
def _get_supported_prefixes(self):
38+
return ["https://huggingface.co"]
39+
40+
def _isfile(self, path):
41+
return path in self.cache_map
3242

3343
PathManager = PathManagerBase()
34-
PathManager.register_handler(DropboxHandler())
44+
PathManager.register_handler(DropboxHandler())
45+
PathManager.register_handler(HuggingfaceHandler())

src/layoutparser/models/detectron2/catalog.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,53 @@
1818

1919
MODEL_CATALOG = {
2020
"HJDataset": {
21-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/6icw6at8m28a2ho/model_final.pth?dl=1",
22-
"mask_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/893paxpy5suvlx9/model_final.pth?dl=1",
23-
"retinanet_R_50_FPN_3x": "https://www.dropbox.com/s/yxsloxu3djt456i/model_final.pth?dl=1",
21+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/HJDataset/faster_rcnn_R_50_FPN_3x/model_final.pth",
22+
"mask_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/HJDataset/mask_rcnn_R_50_FPN_3x/model_final.pth",
23+
"retinanet_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/HJDataset/retinanet_R_50_FPN_3x/model_final.pth",
2424
},
2525
"PubLayNet": {
26-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/dgy9c10wykk4lq4/model_final.pth?dl=1",
27-
"mask_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/d9fc9tahfzyl6df/model_final.pth?dl=1",
28-
"mask_rcnn_X_101_32x8d_FPN_3x": "https://www.dropbox.com/s/57zjbwv6gh3srry/model_final.pth?dl=1",
26+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PubLayNet/faster_rcnn_R_50_FPN_3x/model_final.pth",
27+
"mask_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PubLayNet/mask_rcnn_R_50_FPN_3x/model_final.pth",
28+
"mask_rcnn_X_101_32x8d_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/model_final.pth",
2929
},
3030
"PrimaLayout": {
31-
"mask_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/h7th27jfv19rxiy/model_final.pth?dl=1"
31+
"mask_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PrimaLayout/mask_rcnn_R_50_FPN_3x/model_final.pth"
3232
},
3333
"NewspaperNavigator": {
34-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/6ewh6g8rqt2ev3a/model_final.pth?dl=1",
34+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/NewspaperNavigator/faster_rcnn_R_50_FPN_3x/model_final.pth",
3535
},
3636
"TableBank": {
37-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/8v4uqmz1at9v72a/model_final.pth?dl=1",
38-
"faster_rcnn_R_101_FPN_3x": "https://www.dropbox.com/s/6vzfk8lk9xvyitg/model_final.pth?dl=1",
37+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/TableBank/faster_rcnn_R_50_FPN_3x/model_final.pth",
38+
"faster_rcnn_R_101_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/TableBank/faster_rcnn_R_101_FPN_3x/model_final.pth",
3939
},
4040
"MFD": {
41-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/7xel0i3iqpm2p8y/model_final.pth?dl=1",
41+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/MFD/faster_rcnn_R_50_FPN_3x/model_final.pth",
4242
},
4343
}
4444

4545
CONFIG_CATALOG = {
4646
"HJDataset": {
47-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/j4yseny2u0hn22r/config.yml?dl=1",
48-
"mask_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/4jmr3xanmxmjcf8/config.yml?dl=1",
49-
"retinanet_R_50_FPN_3x": "https://www.dropbox.com/s/z8a8ywozuyc5c2x/config.yml?dl=1",
47+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/HJDataset/faster_rcnn_R_50_FPN_3x/config.yml",
48+
"mask_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/HJDataset/mask_rcnn_R_50_FPN_3x/config.yml",
49+
"retinanet_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/HJDataset/retinanet_R_50_FPN_3x/config.yml",
5050
},
5151
"PubLayNet": {
52-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/f3b12qc4hc0yh4m/config.yml?dl=1",
53-
"mask_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/u9wbsfwz4y0ziki/config.yml?dl=1",
54-
"mask_rcnn_X_101_32x8d_FPN_3x": "https://www.dropbox.com/s/nau5ut6zgthunil/config.yaml?dl=1",
52+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PubLayNet/faster_rcnn_R_50_FPN_3x/config.yml",
53+
"mask_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PubLayNet/mask_rcnn_R_50_FPN_3x/config.yml",
54+
"mask_rcnn_X_101_32x8d_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config.yml",
5555
},
5656
"PrimaLayout": {
57-
"mask_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/yc92x97k50abynt/config.yaml?dl=1"
57+
"mask_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/PrimaLayout/mask_rcnn_R_50_FPN_3x/config.yml"
5858
},
5959
"NewspaperNavigator": {
60-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/wnido8pk4oubyzr/config.yml?dl=1",
60+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/NewspaperNavigator/faster_rcnn_R_50_FPN_3x/config.yml",
6161
},
6262
"TableBank": {
63-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/7cqle02do7ah7k4/config.yaml?dl=1",
64-
"faster_rcnn_R_101_FPN_3x": "https://www.dropbox.com/s/h63n6nv51kfl923/config.yaml?dl=1",
63+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/TableBank/faster_rcnn_R_50_FPN_3x/config.yml",
64+
"faster_rcnn_R_101_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/TableBank/faster_rcnn_R_101_FPN_3x/config.yml",
6565
},
6666
"MFD": {
67-
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/ld9izb95f19369w/config.yaml?dl=1",
67+
"faster_rcnn_R_50_FPN_3x": "https://huggingface.co/layoutparser/detectron2/resolve/main/MFD/faster_rcnn_R_50_FPN_3x/config.yml",
6868
},
6969
}
7070

src/layoutparser/models/effdet/catalog.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
MODEL_CATALOG = {
2020
"PubLayNet": {
21-
"tf_efficientdet_d0": "https://www.dropbox.com/s/ukbw5s673633hsw/publaynet-tf_efficientdet_d0.pth.tar?dl=1",
22-
"tf_efficientdet_d1": "https://www.dropbox.com/s/gxy11xkkiwnpgog/publaynet-tf_efficientdet_d1.pth.tar?dl=1"
21+
"tf_efficientdet_d0": "https://huggingface.co/layoutparser/efficientdet/resolve/main/PubLayNet/tf_efficientdet_d0/publaynet-tf_efficientdet_d0.pth.tar",
22+
"tf_efficientdet_d1": "https://huggingface.co/layoutparser/efficientdet/resolve/main/PubLayNet/tf_efficientdet_d1/publaynet-tf_efficientdet_d1.pth.tar"
2323
},
2424
"MFD": {
25-
"tf_efficientdet_d0": "https://www.dropbox.com/s/dkr22iux7thlhel/mfd-tf_efficientdet_d0.pth.tar?dl=1",
26-
"tf_efficientdet_d1": "https://www.dropbox.com/s/icmbiaqr5s9bz1x/mfd-tf_efficientdet_d1.pth.tar?dl=1"
25+
"tf_efficientdet_d0": "https://huggingface.co/layoutparser/efficientdet/resolve/main/MFD/tf_efficientdet_d0/mfd-tf_efficientdet_d0.pth.tar",
26+
"tf_efficientdet_d1": "https://huggingface.co/layoutparser/efficientdet/resolve/main/MFD/tf_efficientdet_d1/mfd-tf_efficientdet_d1.pth.tar"
2727
}
2828
}
2929

0 commit comments

Comments
 (0)