1313# limitations under the License.
1414from __future__ import absolute_import
1515import logging
16+ import os
17+ import sys
18+
19+ def add_dll_search_dir (dir_path ):
20+ os .environ ["path" ] = dir_path + ";" + os .environ ["path" ]
21+ sys .path .insert (0 , dir_path )
22+ if sys .version_info [:2 ] >= (3 , 8 ):
23+ os .add_dll_directory (dir_path )
24+
25+ if os .name == "nt" :
26+ current_path = os .path .abspath (__file__ )
27+ dirname = os .path .dirname (current_path )
28+ third_libs_dir = os .path .join (dirname , "libs" )
29+ add_dll_search_dir (third_libs_dir )
30+ for root , dirs , filenames in os .walk (third_libs_dir ):
31+ for d in dirs :
32+ if d == "lib" :
33+ add_dll_search_dir (os .path .join (dirname , root , d ))
34+
1635from .fastdeploy_main import Frontend , Backend , FDDataType , TensorInfo , Device
1736from .fastdeploy_runtime import *
1837from . import fastdeploy_main as C
1938from . import vision
2039from .download import download , download_and_decompress
2140
22-
2341def TensorInfoStr (tensor_info ):
2442 message = "TensorInfo(name : '{}', dtype : '{}', shape : '{}')" .format (
2543 tensor_info .name , tensor_info .dtype , tensor_info .shape )
@@ -28,7 +46,7 @@ def TensorInfoStr(tensor_info):
2846
2947class RuntimeOption :
3048 def __init__ (self ):
31- self ._option = C .RuntimeOption ()
49+ self ._option = C .RuntimeOption ()
3250
3351 def set_model_path (self , model_path , params_path = "" , model_format = "paddle" ):
3452 return self ._option .set_model_path (model_path , params_path , model_format )
@@ -103,5 +121,6 @@ def RuntimeOptionStr(runtime_option):
103121 message .strip ("\n " )
104122 message += ")"
105123 return message
124+
106125C .TensorInfo .__repr__ = TensorInfoStr
107- C .RuntimeOption .__repr__ = RuntimeOptionStr
126+ C .RuntimeOption .__repr__ = RuntimeOptionStr
0 commit comments