Skip to content

Commit d631320

Browse files
committed
adding classifier updates to visual recognition
1 parent 311d2ec commit d631320

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

examples/conversation_v1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22
from watson_developer_cloud import ConversationV1
33

4-
54
conversation = ConversationV1(
65
username='YOUR SERVICE USERNAME',
76
password='YOUR SERVICE PASSWORD',

examples/visual_recognition_v3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
# print(json.dumps(visual_recognition.get_classifier('YOUR CLASSIFIER ID'), indent=2))
2020

21+
# with open('../resources/car.jpg', 'rb') as image_file:
22+
# print(json.dumps(visual_recognition.update_classifier('CarsvsTrucks_1479118188',
23+
# cars_positive_examples=image_file), indent=2))
24+
2125
print(json.dumps(visual_recognition.classify(images_url=test_url), indent=2))
2226

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

watson_developer_cloud/visual_recognition_v3.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ def create_classifier(self, name, **kwargs):
8181
return self.request(method='POST', url='/v3/classifiers', files=kwargs, data=data, params=params,
8282
accept_json=True)
8383

84+
def update_classifier(self, classifier_id, **kwargs):
85+
"""
86+
Updates an existing classifier by adding images to existing or new classes.
87+
:param classifier_id: The id of the classifier to update.
88+
:param <NAME>_positive_examples: zip files of images that depict the subject of the class.
89+
:param negative_examples: A zip file of images that do not depict the subject of any of the classes.
90+
:return:
91+
"""
92+
93+
params = {'version': self.version}
94+
# Params sent as url parameters here
95+
return self.request(method='POST', url='/v3/classifiers/{0}'.format(classifier_id), files=kwargs,
96+
params=params, accept_json=True)
97+
8498
def _image_call(self, url, images_file=None, images_url=None, params=None):
8599
if images_file is None and images_url is None:
86100
raise AssertionError('You must specify either a file or a url')

0 commit comments

Comments
 (0)