Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10231619master
| @@ -1,3 +1,5 @@ | |||||
| # Part of the implementation is borrowed and modified from MMDetection, publicly available at | |||||
| # https://github.com/open-mmlab/mmdetection/blob/master/mmdet/datasets/coco.py | |||||
| import os.path as osp | import os.path as osp | ||||
| import tempfile | import tempfile | ||||
| from collections import OrderedDict | from collections import OrderedDict | ||||
| @@ -1,5 +1,5 @@ | |||||
| # Modified from: https://github.com/microsoft/Swin-Transformer/blob/main/models/swin_transformer.py | |||||
| # The implementation is adopted from Swin Transformer, made publicly available under the MIT License at | |||||
| # https://github.com/microsoft/Swin-Transformer/blob/main/models/swin_transformer.py | |||||
| import numpy as np | import numpy as np | ||||
| import torch | import torch | ||||
| import torch.nn as nn | import torch.nn as nn | ||||
| @@ -1,3 +1,5 @@ | |||||
| # Part of the implementation is borrowed and modified from MMDetection, publicly available at | |||||
| # https://github.com/open-mmlab/mmdetection/blob/master/mmdet/models/detectors/two_stage.py | |||||
| import os | import os | ||||
| from collections import OrderedDict | from collections import OrderedDict | ||||
| @@ -1 +1,2 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| from .transforms import build_preprocess_transform | from .transforms import build_preprocess_transform | ||||
| @@ -1,3 +1,4 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| import os.path as osp | import os.path as osp | ||||
| import numpy as np | import numpy as np | ||||
| @@ -51,9 +52,9 @@ class LoadImageFromFile: | |||||
| """Load an image from file. | """Load an image from file. | ||||
| Required keys are "img_prefix" and "img_info" (a dict that must contain the | Required keys are "img_prefix" and "img_info" (a dict that must contain the | ||||
| key "filename"). Added or updated keys are "filename", "img", "img_shape", | |||||
| "ori_shape" (same as `img_shape`), "pad_shape" (same as `img_shape`), | |||||
| "scale_factor" (1.0) and "img_norm_cfg" (means=0 and stds=1). | |||||
| key "filename", "ann_file", and "classes"). Added or updated keys are | |||||
| "filename", "ori_filename", "img", "img_shape", "ori_shape" (same as `img_shape`), | |||||
| "img_fields", "ann_file" (path to annotation file) and "classes". | |||||
| Args: | Args: | ||||
| to_float32 (bool): Whether to convert the loaded image to a float32 | to_float32 (bool): Whether to convert the loaded image to a float32 | ||||
| @@ -73,7 +74,7 @@ class LoadImageFromFile: | |||||
| """Call functions to load image and get image meta information. | """Call functions to load image and get image meta information. | ||||
| Args: | Args: | ||||
| results (dict): Result dict from :obj:`ImageInstanceSegmentationDataset`. | |||||
| results (dict): Result dict from :obj:`ImageInstanceSegmentationCocoDataset`. | |||||
| Returns: | Returns: | ||||
| dict: The dict contains loaded image and meta information. | dict: The dict contains loaded image and meta information. | ||||
| @@ -1,3 +1,4 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| import os | import os | ||||
| from typing import Any, Dict | from typing import Any, Dict | ||||
| @@ -1,3 +1,5 @@ | |||||
| # Part of the implementation is borrowed and modified from MMDetection, publicly available at | |||||
| # https://github.com/open-mmlab/mmdetection/blob/master/mmdet/core/visualization/image.py | |||||
| import itertools | import itertools | ||||
| import cv2 | import cv2 | ||||
| @@ -1,3 +1,5 @@ | |||||
| # Part of the implementation is borrowed and modified from MMDetection, publicly available at | |||||
| # https://github.com/open-mmlab/mmdetection/blob/master/mmdet/datasets/coco.py | |||||
| import os.path as osp | import os.path as osp | ||||
| import numpy as np | import numpy as np | ||||
| @@ -1,3 +1,4 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| import os | import os | ||||
| from typing import Any, Dict, Optional, Union | from typing import Any, Dict, Optional, Union | ||||
| @@ -1,3 +1,4 @@ | |||||
| # Copyright (c) Alibaba, Inc. and its affiliates. | |||||
| from modelscope.metainfo import Trainers | from modelscope.metainfo import Trainers | ||||
| from modelscope.trainers.builder import TRAINERS | from modelscope.trainers.builder import TRAINERS | ||||
| from modelscope.trainers.trainer import EpochBasedTrainer | from modelscope.trainers.trainer import EpochBasedTrainer | ||||