Skip to content

Add copyright and open-source attribution headers #824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,6 @@ dmypy.json

# mindspore compile related
rank_*/

# DS_Store (MacOS)
.DS_Store
17 changes: 17 additions & 0 deletions deploy/py_infer/src/data_process/postprocess/det_db_postprocess.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleOCR
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import os
import sys
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleOCR
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleOCR
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys
from typing import Tuple
Expand Down
5 changes: 5 additions & 0 deletions mindocr/data/layout_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This code is adapted from https://github.com/ultralytics/yolov5
# with modifications to run on MindSpore.

# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license

import glob
import hashlib
import json
Expand Down
3 changes: 3 additions & 0 deletions mindocr/data/transforms/rec_abinet_transforms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This code is adapted from https://github.com/FangShancheng/ABINet
# with modifications to run on MindSpore.

"""
transform for text recognition tasks.
"""
Expand Down
16 changes: 16 additions & 0 deletions mindocr/data/transforms/rec_transforms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleOCR
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
transform for text recognition tasks.
"""
Expand Down
16 changes: 16 additions & 0 deletions mindocr/data/transforms/svtr_transform.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleOCR
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import copy
import logging
import math
Expand Down
17 changes: 17 additions & 0 deletions mindocr/data/transforms/table_transform.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleOCR
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

import cv2
Expand Down
3 changes: 3 additions & 0 deletions mindocr/models/backbones/blocks/magca.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This code is adapted from https://github.com/JiaquanYe/TableMASTER-mmocr
# with modifications to run on MindSpore.

import mindspore.nn as nn
import mindspore.ops as ops
from mindspore import Tensor
Expand Down
2 changes: 2 additions & 0 deletions mindocr/models/backbones/layoutlmv3/layoutlmv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ def construct(
return (sequence_output,) + encoder_outputs[1:]


# This code is adapted from
# https://github.com/facebookresearch/detectron2/blob/main/detectron2/modeling/backbone/fpn.py
class FPNForLayout(FPN):
def __init__(self,
bottom_up,
Expand Down
17 changes: 17 additions & 0 deletions mindocr/models/backbones/layoutxlm/configuration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleNLP
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from dataclasses import dataclass


Expand Down
5 changes: 5 additions & 0 deletions mindocr/models/backbones/layoutxlm/resnet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This code is adapted from https://github.com/facebookresearch/detectron2
# with modifications to run on MindSpore.

# Copyright (c) Facebook, Inc. and its affiliates.

from dataclasses import dataclass
from typing import Optional

Expand Down
18 changes: 18 additions & 0 deletions mindocr/models/backbones/layoutxlm/tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleNLP
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List, Optional

import sentencepiece as spm
Expand Down
19 changes: 19 additions & 0 deletions mindocr/models/backbones/layoutxlm/tokenizer_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleNLP
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import bisect
import io
import itertools
Expand Down
19 changes: 19 additions & 0 deletions mindocr/models/backbones/layoutxlm/tokenizer_utils_base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All Rights Reserved.
# Copyright (c) 2020, PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleNLP
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import copy
import io
import json
Expand Down
17 changes: 17 additions & 0 deletions mindocr/models/backbones/layoutxlm/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleNLP
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import functools
import inspect
import os
Expand Down
5 changes: 5 additions & 0 deletions mindocr/models/backbones/layoutxlm/visual_backbone.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This code is adapted from https://github.com/facebookresearch/detectron2
# with modifications to run on MindSpore.

# Copyright (c) Facebook, Inc. and its affiliates.

import math
import os

Expand Down
17 changes: 17 additions & 0 deletions mindocr/models/backbones/layoutxlm/vocab.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# This code is adapted from https://github.com/PaddlePaddle/PaddleNLP
# with modifications to run on MindSpore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import collections
import io
import json
Expand Down
7 changes: 7 additions & 0 deletions mindocr/models/backbones/mindcv_models/coat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# This code is adapted from https://github.com/huggingface/pytorch-image-models
# with modifications to run on MindSpore.
"""
CoaT architecture.

Paper: Co-Scale Conv-Attentional Image Transformers - https://arxiv.org/abs/2104.06399

Official CoaT code at: https://github.com/mlpc-ucsd/CoaT

Modified from timm/models/vision_transformer.py
"""
from typing import Union
Expand Down
26 changes: 23 additions & 3 deletions mindocr/models/backbones/mindcv_models/crossvit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# This code is adapted from https://github.com/huggingface/pytorch-image-models
# with modifications to run on MindSpore.

""" CrossViT Model

@inproceedings{
chen2021crossvit,
title={{CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification}},
author={Chun-Fu (Richard) Chen and Quanfu Fan and Rameswar Panda},
booktitle={International Conference on Computer Vision (ICCV)},
year={2021}
}

Paper link: https://arxiv.org/abs/2103.14899
Original code: https://github.com/IBM/CrossViT/blob/main/models/crossvit.py

NOTE: model names have been renamed from originals to represent actual input res all *_224 -> *_240 and *_384 -> *_408

Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman
Modified from Timm. https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py
"""
MindSpore implementation of `crossvit`.
Refer to crossvit: Cross-Attention Multi-Scale Vision Transformer for Image Classification
"""

# Copyright IBM All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

import numpy as np

Expand Down
9 changes: 6 additions & 3 deletions mindocr/models/backbones/mindcv_models/densenet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
MindSpore implementation of `DenseNet`.
Refer to: Densely Connected Convolutional Networks
# This code is adapted from https://github.com/huggingface/pytorch-image-models
# with modifications to run on MindSpore.

"""Pytorch Densenet implementation w/ tweaks
This file is a copy of https://github.com/pytorch/vision 'densenet.py' (BSD-3-Clause) with
fixed kwargs passthrough and addition of dynamic global avg/max pool.
"""

import math
Expand Down
Loading