|
1 | 1 | from __future__ import print_function |
2 | 2 | import json |
3 | 3 | from os.path import join, dirname |
4 | | -from watson_developer_cloud import VisualRecognitionV3 |
| 4 | +from watson_developer_cloud import VisualRecognitionV3, WatsonApiException |
5 | 5 |
|
6 | 6 | test_url = 'https://www.ibm.com/ibm/ginni/images' \ |
7 | 7 | '/ginni_bio_780x981_v4_03162016.jpg' |
|
24 | 24 | parameters=parameters) |
25 | 25 | print(json.dumps(car_results, indent=2)) |
26 | 26 |
|
| 27 | +# Example with no deprecated |
| 28 | +try: |
| 29 | + with open(car_path, 'rb') as images_file: |
| 30 | + car_results = visual_recognition.classify( |
| 31 | + images_file=images_file, |
| 32 | + threshold='0.1', |
| 33 | + classifier_ids=[classifier_id, 'default']) |
| 34 | + print(json.dumps(car_results, indent=2)) |
| 35 | +except WatsonApiException as ex: |
| 36 | + print(ex.httpResponse.json()) |
| 37 | + |
27 | 38 | # print(json.dumps(visual_recognition.get_classifier('YOUR CLASSIFIER ID'), |
28 | 39 | # indent=2)) |
29 | 40 |
|
|
56 | 67 | print(json.dumps(face_result, indent=2)) |
57 | 68 |
|
58 | 69 | #Core ml model example |
59 | | -core_ml_model = visual_recognition.get_core_ml_model(classifier_id) |
60 | | -with open('/tmp/CarsvsTrucks.mlmodel', 'wb') as fp: |
61 | | - fp.write(core_ml_model.content) |
| 70 | +# model_name = '{0}.mlmodel'.format(classifier_id) |
| 71 | +# core_ml_model = visual_recognition.get_core_ml_model(classifier_id) |
| 72 | +# with open('/tmp/{0}'.format(model_name), 'wb') as fp: |
| 73 | +# fp.write(core_ml_model.content) |
0 commit comments