Skip to content

Commit d1ffbf4

Browse files
committed
fix: fix the image path error in the url input from the cli
1 parent f2e3906 commit d1ffbf4

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ results.vis(save_dir="outputs", save_name="vis")
210210
#### 📦 终端运行
211211

212212
```bash
213-
rapid_table test_images/table.jpg -v
213+
rapid_table https://raw.githubusercontent.com/RapidAI/RapidTable/refs/heads/main/tests/test_files/table.jpg -v
214214
```
215215

216216
### 📝 结果

rapid_table/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_table_matcher(self, pred_structures, cell_bboxes, dt_boxes, rec_res):
109109

110110
def parse_args(arg_list: Optional[List[str]] = None):
111111
parser = argparse.ArgumentParser()
112-
parser.add_argument("img_path", type=Path, help="Path to image for layout.")
112+
parser.add_argument("img_path", type=str, help="the image path or URL of the table")
113113
parser.add_argument(
114114
"-m",
115115
"--model_type",
@@ -145,8 +145,8 @@ def main(arg_list: Optional[List[str]] = None):
145145
print(table_results.pred_html)
146146

147147
if args.vis:
148-
save_dir = img_path.resolve().parent
149-
table_results.vis(save_dir, save_name=img_path.stem)
148+
save_dir = Path(img_path).resolve().parent
149+
table_results.vis(save_dir, save_name=Path(img_path).stem)
150150

151151

152152
if __name__ == "__main__":

tests/test_main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
test_file_dir = cur_dir / "test_files"
2222
img_path = str(test_file_dir / "table.jpg")
23+
img_url = "https://raw.githubusercontent.com/RapidAI/RapidTable/refs/heads/main/tests/test_files/table.jpg"
2324

2425

2526
def test_only_table():
@@ -41,9 +42,12 @@ def test_without_txt_table():
4142

4243
@pytest.mark.parametrize(
4344
"command, expected_output",
44-
[(f"{img_path} --model_type slanet_plus", 1274)],
45+
[
46+
(f"{img_path} --model_type slanet_plus", 1274),
47+
(f"{img_url} --model_type slanet_plus", 1274),
48+
],
4549
)
46-
def test_main(capsys, command, expected_output):
50+
def test_main_cli(capsys, command, expected_output):
4751
main(shlex.split(command))
4852
output = capsys.readouterr().out.rstrip()
4953
assert len(output) == expected_output

0 commit comments

Comments
 (0)