|
7 | 7 | import requests |
8 | 8 |
|
9 | 9 | url = "http://localhost:9003/ocr" |
10 | | -img_path = "../python/tests/test_files/ch_en_num.jpg" |
| 10 | +img_path = "tests/test_files/ch_en_num.jpg" |
11 | 11 |
|
12 | 12 | # 方式一:使用base64编码传 |
13 | 13 | stime = time.time() |
|
23 | 23 |
|
24 | 24 | print("-" * 40) |
25 | 25 |
|
26 | | -# 方式二:使用文件上传方式 |
27 | | -stime = time.time() |
28 | | -with open(img_path, "rb") as f: |
29 | | - file_dict = {"image_file": (img_path, f, "image/png")} |
30 | | - response = requests.post(url, files=file_dict) # , timeout=60 |
31 | | - print(response.json()) |
32 | | - |
33 | | -etime = time.time() - stime |
34 | | -print(f"用时:{etime:.3f}秒") |
35 | | -print("-" * 40) |
36 | | - |
37 | | -# 方式三:控制是否使用检测、方向分类和识别这三部分的模型; 不使用检测模型:use_det=False |
38 | | -stime = time.time() |
39 | | -img_path = "../python/tests/test_files/test_without_det.jpg" |
40 | | - |
41 | | -with open(img_path, "rb") as f: |
42 | | - file_dict = {"image_file": (img_path, f, "image/png")} |
43 | | - # 添加控制参数 |
44 | | - data = {"use_det": False, "use_cls": True, "use_rec": True} |
45 | | - response = requests.post(url, files=file_dict, data=data) # , timeout=60 |
46 | | - print(response.json()) |
47 | | - |
48 | | -etime = time.time() - stime |
49 | | -print(f"用时:{etime:.3f}秒") |
50 | | -print("-" * 40) |
| 26 | +# # 方式二:使用文件上传方式 |
| 27 | +# stime = time.time() |
| 28 | +# with open(img_path, "rb") as f: |
| 29 | +# file_dict = {"image_file": (img_path, f, "image/png")} |
| 30 | +# response = requests.post(url, files=file_dict) # , timeout=60 |
| 31 | +# print(response.json()) |
| 32 | + |
| 33 | +# etime = time.time() - stime |
| 34 | +# print(f"用时:{etime:.3f}秒") |
| 35 | +# print("-" * 40) |
| 36 | + |
| 37 | +# # 方式三:控制是否使用检测、方向分类和识别这三部分的模型; 不使用检测模型:use_det=False |
| 38 | +# stime = time.time() |
| 39 | +# img_path = "../python/tests/test_files/test_without_det.jpg" |
| 40 | + |
| 41 | +# with open(img_path, "rb") as f: |
| 42 | +# file_dict = {"image_file": (img_path, f, "image/png")} |
| 43 | +# # 添加控制参数 |
| 44 | +# data = {"use_det": False, "use_cls": True, "use_rec": True} |
| 45 | +# response = requests.post(url, files=file_dict, data=data) # , timeout=60 |
| 46 | +# print(response.json()) |
| 47 | + |
| 48 | +# etime = time.time() - stime |
| 49 | +# print(f"用时:{etime:.3f}秒") |
| 50 | +# print("-" * 40) |
0 commit comments