Skip to content

Commit

Permalink
general-ocr打开方向检测开关
Browse files Browse the repository at this point in the history
  • Loading branch information
longchao1916 committed Mar 20, 2024
1 parent b455d24 commit 183bf41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
1 change: 0 additions & 1 deletion appbuilder/core/components/general_ocr/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def tool_eval(self, name: str, streaming: bool, **kwargs):
"识别结果": " \n".join(item["words"] for item in result["words_result"])
}
res = json.dumps(results, ensure_ascii=False, indent=4)
print(res)
if streaming:
yield {
"type": "text",
Expand Down
14 changes: 2 additions & 12 deletions appbuilder/tests/test_general_ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ def setUp(self):
Returns:
None.
"""
import os
os.environ["GATEWAY_URL"] = "https://apaas-api.test.baidu-int.com"
os.environ["APPBUILDER_TOKEN"] = \
"Bearer bce-v3/ALTAK-XKQZTTmtiBRWFOXTRNkkW/71d288bbbdd824ab7804d3795a71e2acd5ad1f3b"
self.general_ocr = appbuilder.GeneralOCR()

def test_run_with_raw_image(self):
Expand All @@ -46,10 +42,7 @@ def test_run_with_raw_image(self):
None
"""
image_url = "https://bj.bcebos.com/v1/appbuilder/general_ocr_test.png?" \
"authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2024-01-" \
"11T10%3A59%3A17Z%2F-1%2Fhost%2F081bf7bcccbda5207c82a4de074628b04ae" \
"857a27513734d765495f89ffa5f73"
image_url = "http://gzbh-ns-map-na029.gzbh.baidu.com:8521/img1.png"
raw_image = requests.get(image_url).content

# Create message with raw_image
Expand Down Expand Up @@ -138,10 +131,7 @@ def test_run_without_image_and_url(self):

def test_tool_eval_valid(self):
"""测试 tool 方法对有效请求的处理。"""
image_url = "https://bj.bcebos.com/v1/appbuilder/general_ocr_test.png?" \
"authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2024-01-" \
"11T10%3A59%3A17Z%2F-1%2Fhost%2F081bf7bcccbda5207c82a4de074628b04ae" \
"857a27513734d765495f89ffa5f73"
image_url = "http://gzbh-ns-map-na029.gzbh.baidu.com:8521/img1.png"
result = self.general_ocr.tool_eval(name="general_ocr", streaming=True, img_url=image_url)
res = [item for item in result]
self.assertNotEqual(len(res), 0)
Expand Down

0 comments on commit 183bf41

Please sign in to comment.