Skip to content

fix some import path for inference #175

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

Merged
merged 1 commit into from
Apr 7, 2023
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
4 changes: 2 additions & 2 deletions deploy/mx_infer/framework/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from ctypes import c_longdouble
from multiprocessing import Manager

from deploy.mx_infer.data_type import ProfilingData
from deploy.mx_infer.utils import log
from mx_infer.data_type import ProfilingData
from mx_infer.utils import log
from .module_data_type import ModuleInitArgs


Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/framework/module_manager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from collections import defaultdict, namedtuple
from multiprocessing import Queue, Process

from deploy.mx_infer.processors import processor_initiator
from deploy.mx_infer.utils import log
from mx_infer.processors import processor_initiator
from mx_infer.utils import log
from .module_data_type import ModulesInfo, ModuleInitArgs

OutputRegisterInfo = namedtuple('OutputRegisterInfo', ['pipeline_name', 'module_send', 'module_recv'])
Expand Down
9 changes: 4 additions & 5 deletions deploy/mx_infer/infer_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import sys

__dir__ = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '../../')))
sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '../../mindocr')))
sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '../'))) # mx_infer path
sys.path.insert(0, os.path.abspath(os.path.join(__dir__, '../..'))) # tools path

from deploy.mx_infer.args import get_args
import deploy.mx_infer.pipeline as pipeline
from mx_infer import pipeline_args, pipeline


def main():
args = get_args()
args = pipeline_args.get_args()
pipeline.build_pipeline(args)


Expand Down
13 changes: 6 additions & 7 deletions deploy/mx_infer/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import tqdm

from deploy.mx_infer.data_type import StopSign
from deploy.mx_infer.framework import ModuleDesc, ModuleConnectDesc, ModuleManager, SupportedTaskOrder
from deploy.mx_infer.processors import MODEL_DICT
from deploy.mx_infer.utils import log, profiling, safe_div, save_path_init, TASK_QUEUE_SIZE
from mx_infer.data_type import StopSign
from mx_infer.framework import ModuleDesc, ModuleConnectDesc, ModuleManager, SupportedTaskOrder
from mx_infer.processors import MODEL_DICT
from mx_infer.utils import log, profiling, safe_div, save_path_init, TASK_QUEUE_SIZE


def image_sender(images_path, send_queue, show_progressbar):
Expand Down Expand Up @@ -144,9 +144,8 @@ def build_pipeline(args):
If the guidelines above are not followed, the inference pipeline cannot be built. Check your args configurations.

Example:
>>> from deploy.mx_infer.args import get_args
>>> import deploy.mx_infer.pipeline as pipeline
>>> args = get_args()
>>> from mx_infer import pipeline_args, pipeline
>>> args = pipeline_args.get_args()
>>> pipeline.build_pipeline(args)
"""

Expand Down
9 changes: 5 additions & 4 deletions deploy/mx_infer/args.py → deploy/mx_infer/pipeline_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import itertools
import os

from deploy.mx_infer.framework.module_data_type import InferModelComb
from deploy.mx_infer.processors import SUPPORT_DET_MODEL, SUPPORT_REC_MODEL
from deploy.mx_infer.utils import log
from mx_infer.framework import InferModelComb
from mx_infer.processors import SUPPORT_DET_MODEL, SUPPORT_REC_MODEL
from mx_infer.utils import log


def str2bool(v):
Expand All @@ -23,7 +23,8 @@ def get_args():
parser.add_argument('--device', type=str, default='Ascend', required=False,
choices=['Ascend'], help='Device type.')
parser.add_argument('--device_id', type=int, default=0, required=False, help='Device id.')
parser.add_argument('--parallel_num', type=int, default=1, required=False, help='Number of parallel in each stage of pipeline parallelism.')
parser.add_argument('--parallel_num', type=int, default=1, required=False,
help='Number of parallel in each stage of pipeline parallelism.')
parser.add_argument('--precision_mode', type=str, default="fp32", choices=['fp16', 'fp32'], required=False,
help='Precision mode.')
parser.add_argument('--det_algorithm', type=str, default='DBNet', choices=SUPPORT_DET_MODEL, required=False,
Expand Down
6 changes: 4 additions & 2 deletions deploy/mx_infer/processors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from sys import modules

from deploy.mx_infer.framework import InferModelComb
from deploy.mx_infer.utils import log
from mx_infer.framework import InferModelComb
from mx_infer.utils import log

from .classification import CLSPreProcess, CLSInferProcess
from .common import HandoutProcess, CollectProcess, DecodeProcess
from .detection import DetPreProcess, DetInferProcess, DetPostProcess, SUPPORT_DET_MODEL
from .recognition import RecPreProcess, RecInferProcess, RecPostProcess, SUPPORT_REC_MODEL


DET_DESC = [('DetPreProcess', 1), ('DetInferProcess', 1), ('DetPostProcess', 1)]
REC_DESC = [('RecPreProcess', 1), ('RecInferProcess', 1), ('RecPostProcess', 1)]
CLS_DESC = [('CLSPreProcess', 1), ('CLSInferProcess', 1)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import numpy as np
from mindx.sdk import base, Tensor

from deploy.mx_infer.framework import ModuleBase
from deploy.mx_infer.utils import check_valid_file
from mx_infer.framework import ModuleBase
from mx_infer.utils import check_valid_file


class CLSInferProcess(ModuleBase):
Expand Down
6 changes: 3 additions & 3 deletions deploy/mx_infer/processors/classification/cls_pre_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
from mindx.sdk import base

from deploy.mx_infer.data_type.process_data import ProcessData
from deploy.mx_infer.framework import ModuleBase
from deploy.mx_infer.utils import get_batch_list_greedy, get_hw_of_img, safe_div, padding_with_cv, normalize, \
from mx_infer.data_type import ProcessData
from mx_infer.framework import ModuleBase
from mx_infer.utils import get_batch_list_greedy, get_hw_of_img, safe_div, padding_with_cv, normalize, \
to_chw_image, expand, padding_batch, bgr_to_gray, get_shape_info, \
check_valid_file, NORMALIZE_MEAN, NORMALIZE_STD, NORMALIZE_SCALE

Expand Down
6 changes: 3 additions & 3 deletions deploy/mx_infer/processors/common/collect_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import cv2
import numpy as np

from deploy.mx_infer.data_type import StopData, ProcessData, ProfilingData
from deploy.mx_infer.framework import ModuleBase, InferModelComb
from deploy.mx_infer.utils import safe_list_writer, log
from mx_infer.data_type import StopData, ProcessData, ProfilingData
from mx_infer.framework import ModuleBase, InferModelComb
from mx_infer.utils import safe_list_writer, log
from tools.utils.visualize import VisMode, Visualization

_RESULTS_SAVE_FILENAME = {
Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/processors/common/decode_process.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from deploy.mx_infer.framework.module_base import ModuleBase
from deploy.mx_infer.utils import safe_img_read, get_hw_of_img
from mx_infer.framework import ModuleBase
from mx_infer.utils import safe_img_read, get_hw_of_img


class DecodeProcess(ModuleBase):
Expand Down
6 changes: 3 additions & 3 deletions deploy/mx_infer/processors/common/handout_process.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from deploy.mx_infer.data_type import ProcessData, StopData, StopSign
from deploy.mx_infer.framework.module_base import ModuleBase
from deploy.mx_infer.utils import log
from mx_infer.data_type import ProcessData, StopData, StopSign
from mx_infer.framework.module_base import ModuleBase
from mx_infer.utils import log


class HandoutProcess(ModuleBase):
Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/processors/detection/det_infer_process.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
from mindx.sdk import base, Tensor

from deploy.mx_infer.framework import ModuleBase
from deploy.mx_infer.utils import get_matched_gear_hw, padding_with_np, \
from mx_infer.framework import ModuleBase
from mx_infer.utils import get_matched_gear_hw, padding_with_np, \
get_shape_info


Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/processors/detection/det_post_process.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import cv2
import numpy as np

from deploy.mx_infer.framework import ModuleBase
from deploy.mx_infer.utils import get_mini_boxes, unclip, construct_box, box_score_slow, \
from mx_infer.framework import ModuleBase
from mx_infer.utils import get_mini_boxes, unclip, construct_box, box_score_slow, \
get_rotate_crop_image, get_hw_of_img, safe_div, box_score_fast


Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/processors/detection/det_pre_process.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from deploy.mx_infer.framework import ModuleBase
from deploy.mx_infer.utils import normalize, to_chw_image, \
from mx_infer.framework import ModuleBase
from mx_infer.utils import normalize, to_chw_image, \
expand, get_hw_of_img, resize_by_limit_max_side, IMAGE_NET_IMAGE_STD, IMAGE_NET_IMAGE_MEAN, DBNET_LIMIT_SIDE, \
NORMALIZE_SCALE

Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/processors/recognition/rec_infer_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import numpy as np
from mindx.sdk import base, Tensor

from deploy.mx_infer.framework import ModuleBase
from deploy.mx_infer.utils import get_shape_info, check_valid_file, check_valid_dir
from mx_infer.framework import ModuleBase
from mx_infer.utils import get_shape_info, check_valid_file, check_valid_dir


class RecInferProcess(ModuleBase):
Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/processors/recognition/rec_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import numpy as np

from deploy.mx_infer.framework import ModuleBase, InferModelComb
from deploy.mx_infer.utils import array_to_texts, file_base_check, log
from mx_infer.framework import ModuleBase, InferModelComb
from mx_infer.utils import array_to_texts, file_base_check, log


class RecPostProcess(ModuleBase):
Expand Down
6 changes: 3 additions & 3 deletions deploy/mx_infer/processors/recognition/rec_pre_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
from mindx.sdk import base

from deploy.mx_infer.data_type.process_data import ProcessData
from deploy.mx_infer.framework import ModuleBase, InferModelComb
from deploy.mx_infer.utils import get_batch_list_greedy, get_hw_of_img, safe_div, get_matched_gear_hw, \
from mx_infer.data_type.process_data import ProcessData
from mx_infer.framework import ModuleBase, InferModelComb
from mx_infer.utils import get_batch_list_greedy, get_hw_of_img, safe_div, get_matched_gear_hw, \
padding_with_cv, normalize, to_chw_image, expand, padding_batch, bgr_to_gray, get_shape_info, \
check_valid_file, check_valid_dir, NORMALIZE_SCALE, NORMALIZE_MEAN, NORMALIZE_STD

Expand Down
4 changes: 2 additions & 2 deletions deploy/mx_infer/utils/safe_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import os
import re
import stat
import json
import shutil
import stat

import cv2

Expand Down