使用图像识别

时间:2017-07-16 08:07:24

标签: ibm-watson watson

有没有办法使用Watsons图像分类功能从文档图像中提取信息?而不是简单地将图像分类为a,b或c?

1 个答案:

答案 0 :(得分:0)

访问here,详细了解 watson visual-recognition

原始代码(最终代码): #just for reference ,阅读如何创建分类器并实现自己的!

import json
from os.path import join, dirname
from watson_developer_cloud import VisualRecognitionV3

test_url = 'https://url-to-ran-image.jpg'

visual_recognition = VisualRecognitionV3('2017-01-11', api_key='YOUR API KEY')


tree_path = join(dirname(__file__), '../resources/trees.zip')
with open(tree_path, 'rb') as images_file:
    tree_results = visual_recognition.classify(images_file=images_file,
                                              threshold=0.1,
                                              classifier_ids=[
                                                  'Carsvsmango_1479118188',
                                                  'default'])
    print(json.dumps(tree_results, indent=2))

url_result = visual_recognition.classify(images_url=test_url)
print(json.dumps(url_result, indent=2))

faces_result = visual_recognition.detect_faces(images_url=test_url)
print(json.dumps(faces_result, indent=2))

print(json.dumps(visual_recognition.list_classifiers(), indent=2))

file_path = join(dirname(__file__), '../some-random-text-image.png')
with open(file_path, 'rb') as image_file:
    text_results = visual_recognition.recognize_text(images_file=image_file)
    print(json.dumps(text_results, indent=2))

face_path = join(dirname(__file__), '../face.jpg')
with open(face_path, 'rb') as image_file:
    face_result = visual_recognition.detect_faces(images_file=image_file)
    print(json.dumps(face_result, indent=2))

图表有助于更好地理解沃森的识别平台。

Watson