@@ -37,6 +37,26 @@ def __init__(self, version, url=default_url, username=None, password=None, use_v
3737 self , 'visual_recognition' , url , username , password , use_vcap_services )
3838 self .version = version
3939
40+ def get_classifier (self , classifier_id ):
41+ """
42+ Retrieves information about a specific classifier.
43+ :param classifier_id: The classifier id
44+ """
45+
46+ params = {'version' : self .version }
47+ return self .request (method = 'GET' , url = '/v2/classifiers/{}' .format (classifier_id ), params = params ,
48+ accept_json = True )
49+
50+ def delete_classifier (self , classifier_id ):
51+ """
52+ Deletes a custom classifier with the specified classifier id.
53+ :param classifier_id: The classifier id
54+ """
55+
56+ params = {'version' : self .version }
57+ return self .request (method = 'DELETE' , url = '/v2/classifiers/{}' .format (classifier_id ), params = params ,
58+ accept_json = True )
59+
4060 def list_classifiers (self , verbose = False ):
4161 """
4262 Returns a list of user-created and built-in classifiers. (May change in the future to only user-created.)
@@ -46,7 +66,29 @@ def list_classifiers(self, verbose=False):
4666 params = {'verbose' : verbose , 'version' : self .version }
4767 return self .request (method = 'GET' , url = '/v2/classifiers' , params = params , accept_json = True )
4868
69+ def create_classifier (self , name , positive_examples , negative_examples ):
70+ """
71+ Train a new classifier from example images which are uploaded.
72+ :param name: The desired short name of the new classifier.
73+ :param positive_examples: A zip file of images that depict the subject of the new classifier.
74+ :param negative_examples: A zip file of images that do not depict the subject of the new classifier.
75+ :return:
76+ """
77+
78+ params = {'version' : self .version }
79+ data = {'name' : name }
80+ # Params sent as url parameters here
81+ return self .request (method = 'POST' , url = '/v2/classifiers' , files = {'positive_examples' : positive_examples ,
82+ 'negative_examples' : negative_examples },
83+ data = data , params = params , accept_json = True )
84+
4985 def classify (self , images_file , classifier_ids = None ):
86+ """
87+ Returns a list of classification scores for one or more input images.
88+ :param images_file: An image file or zip file of image files to analyze.
89+ :param classifier_ids: The ids of classifiers to consider. When absence, considers all classifiers.
90+ :return:
91+ """
5092
5193 if isinstance (classifier_ids , list ):
5294 classifier_ids = json .dumps (classifier_ids )
0 commit comments