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: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ if(ENABLE_TEXT)
endif()

configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h)
configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/pybind/main.cc.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/pybind/main.cc)
configure_file(${PROJECT_SOURCE_DIR}/FastDeploy.cmake.in ${PROJECT_SOURCE_DIR}/FastDeploy.cmake @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/fastdeploy/c_lib_wrap.py.in ${PROJECT_SOURCE_DIR}/fastdeploy/c_lib_wrap.py)

list(REMOVE_ITEM ALL_DEPLOY_SRCS ${DEPLOY_PYBIND_SRCS})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cv::Mat PyArrayToCvMat(pybind11::array& pyarray) {
}
#endif

PYBIND11_MODULE(fastdeploy_main, m) {
PYBIND11_MODULE(@PY_LIBRARY_NAME@, m) {
m.doc() =
"Make programer easier to deploy deeplearning model, save time to save "
"the world!";
Expand Down
51 changes: 2 additions & 49 deletions fastdeploy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,9 @@
import os
import sys

try:
import paddle
except:
pass


def add_dll_search_dir(dir_path):
os.environ["path"] = dir_path + ";" + os.environ["path"]
sys.path.insert(0, dir_path)
if sys.version_info[:2] >= (3, 8):
os.add_dll_directory(dir_path)


if os.name == "nt":
current_path = os.path.abspath(__file__)
dirname = os.path.dirname(current_path)
third_libs_dir = os.path.join(dirname, "libs")
add_dll_search_dir(third_libs_dir)
for root, dirs, filenames in os.walk(third_libs_dir):
for d in dirs:
if d == "lib" or d == "bin":
add_dll_search_dir(os.path.join(dirname, root, d))

from .fastdeploy_main import Frontend, Backend, FDDataType, TensorInfo, Device
from .c_lib_wrap import Frontend, Backend, FDDataType, TensorInfo, Device
from .runtime import Runtime, RuntimeOption
from .model import FastDeployModel
from . import fastdeploy_main as C
from . import c_lib_wrap as C
from . import vision
from .download import download, download_and_decompress


def TensorInfoStr(tensor_info):
message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')".format(
tensor_info.name, tensor_info.dtype, tensor_info.shape)
return message


def RuntimeOptionStr(runtime_option):
attrs = dir(runtime_option)
message = "RuntimeOption(\n"
for attr in attrs:
if attr.startswith("__"):
continue
if hasattr(getattr(runtime_option, attr), "__call__"):
continue
message += " {} : {}\t\n".format(attr, getattr(runtime_option, attr))
message.strip("\n")
message += ")"
return message


C.TensorInfo.__repr__ = TensorInfoStr
C.RuntimeOption.__repr__ = RuntimeOptionStr
59 changes: 59 additions & 0 deletions fastdeploy/c_lib_wrap.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# 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 __future__ import absolute_import
import logging
import os
import sys

def add_dll_search_dir(dir_path):
os.environ["path"] = dir_path + ";" + os.environ["path"]
sys.path.insert(0, dir_path)
if sys.version_info[:2] >= (3, 8):
os.add_dll_directory(dir_path)


if os.name == "nt":
current_path = os.path.abspath(__file__)
dirname = os.path.dirname(current_path)
third_libs_dir = os.path.join(dirname, "libs")
add_dll_search_dir(third_libs_dir)
for root, dirs, filenames in os.walk(third_libs_dir):
for d in dirs:
if d == "lib" or d == "bin":
add_dll_search_dir(os.path.join(dirname, root, d))

from .@PY_LIBRARY_NAME@ import *

def TensorInfoStr(tensor_info):
message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')".format(
tensor_info.name, tensor_info.dtype, tensor_info.shape)
return message


def RuntimeOptionStr(runtime_option):
attrs = dir(runtime_option)
message = "RuntimeOption(\n"
for attr in attrs:
if attr.startswith("__"):
continue
if hasattr(getattr(runtime_option, attr), "__call__"):
continue
message += " {} : {}\t\n".format(attr, getattr(runtime_option, attr))
message.strip("\n")
message += ")"
return message


TensorInfo.__repr__ = TensorInfoStr
RuntimeOption.__repr__ = RuntimeOptionStr
2 changes: 1 addition & 1 deletion fastdeploy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from __future__ import absolute_import
import logging
from . import fastdeploy_main as C
from . import c_lib_wrap as C


class FastDeployModel:
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from __future__ import absolute_import
import logging
from . import fastdeploy_main as C
from . import c_lib_wrap as C


class Runtime:
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/biubug6/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class RetinaFace(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/deepcam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class YOLOv5Face(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/deepinsight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class SCRFD(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/linzaer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class UltraFace(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/megvii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class YOLOX(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/meituan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class YOLOv6(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ppcls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class Model(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ppdet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class PPYOLOE(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ppogg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class YOLOv5Lite(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ppseg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class Model(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/rangilyu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class NanoDetPlus(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/ultralytics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class YOLOv5(FastDeployModel):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/visualize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import absolute_import
import logging
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


def vis_detection(im_data, det_result, line_size=1, font_size=0.5):
Expand Down
2 changes: 1 addition & 1 deletion fastdeploy/vision/wongkinyiu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C
from ... import c_lib_wrap as C


class YOLOv7(FastDeployModel):
Expand Down
Loading