1616from rapid_table .utils import DownloadModel , LoadImage , Logger , VisTable
1717
1818from .table_matcher import TableMatch
19- from . table_structure import TableStructurer , TableStructureUnitable
19+
2020
2121logger = Logger (logger_name = __name__ ).get_log ()
2222root_dir = Path (__file__ ).resolve ().parent
@@ -59,7 +59,12 @@ class RapidTableOutput:
5959
6060
6161class RapidTable :
62- def __init__ (self , config : RapidTableInput ):
62+ def __init__ (self , config : Optional [RapidTableInput ] = None ):
63+ if config is None :
64+ config = RapidTableInput ()
65+ if not isinstance (config , RapidTableInput ):
66+ raise TypeError (f"config must be an instance of RapidTableInput, but got { type (config )} " )
67+
6368 self .model_type = config .model_type
6469 if self .model_type not in KEY_TO_MODEL_URL :
6570 model_list = "," .join (KEY_TO_MODEL_URL )
@@ -69,8 +74,10 @@ def __init__(self, config: RapidTableInput):
6974
7075 config .model_path = self .get_model_path (config .model_type , config .model_path )
7176 if self .model_type == ModelType .UNITABLE .value :
77+ from .table_structure .table_structure_unitable import TableStructureUnitable
7278 self .table_structure = TableStructureUnitable (asdict (config ))
7379 else :
80+ from .table_structure .table_structure import TableStructurer
7481 self .table_structure = TableStructurer (asdict (config ))
7582
7683 self .table_matcher = TableMatch ()
0 commit comments