Skip to content

Commit b9adda2

Browse files
authored
Merge pull request #97 from hbh112233abc/main
config传参默认可以不传,解决默认onnx,报须torch库的问题
2 parents b3b1f30 + 7ba8fba commit b9adda2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

rapid_table/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from rapid_table.utils import DownloadModel, LoadImage, Logger, VisTable
1717

1818
from .table_matcher import TableMatch
19-
from .table_structure import TableStructurer, TableStructureUnitable
19+
2020

2121
logger = Logger(logger_name=__name__).get_log()
2222
root_dir = Path(__file__).resolve().parent
@@ -59,7 +59,12 @@ class RapidTableOutput:
5959

6060

6161
class 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()

rapid_table/table_structure/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from .table_structure import TableStructurer
15-
from .table_structure_unitable import TableStructureUnitable
14+

0 commit comments

Comments
 (0)