Reputation: 3
I am a beginner in using Watson Visual Recognition and am trying to create a custom classifier to classify dog images. However, when trying to create my classifier as shown in the code snippet below, I get an error.
with open ('beagle.zip','rb') as beagles,open ('golden-retriever.zip','rb') as golden_retrievers,open `('husky.zip','rb') as huskies:`
classifier = visrec.create_classifier(name = 'dog_classifier',positive_examples = `{'beagles':beagles,'golden_retrievers':golden_retrievers,'huskies': 'huskies'})`
Here is the error:
classifier = visrec.create_classifier(name = 'dog_classifier',positive_examples = {'beagles':beagles,'golden_retrievers':golden_retrievers,'huskies': 'huskies'})
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ibm_watson/visual_recognition_v3.py", line 282, in create_classifier
response = self.send(request)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ibm_cloud_sdk_core/base_service.py", line 302, in send
raise ApiException(response.status_code, http_response=response)
ibm_cloud_sdk_core.api_exception.ApiException: Error: <HTML><HEAD>
<TITLE>Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error - Write</H1>
The server encountered an internal error or misconfiguration and was unable to
complete your request.<P>
Reference #4.9436d517.1617113574.3744472
</BODY></HTML>
, Code: 503
How can I fix this?
Upvotes: 0
Views: 701
Reputation: 4737
503
indicates that the service is unavailable. If could have been down when you were trying to hit it.
Current status shows it is up - https://cloud.ibm.com/status
Are you still getting the same error?
Sample code from the API documentation (https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v3?code=python#createclassifier) is
import json
from ibm_watson import VisualRecognitionV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
authenticator = IAMAuthenticator('{apikey}')
visual_recognition = VisualRecognitionV3(
version='2018-03-19',
authenticator=authenticator
)
visual_recognition.set_service_url('{url}')
with open('./beagle.zip', 'rb') as beagle, open(
'./golden-retriever.zip', 'rb') as goldenretriever, open(
'./husky.zip', 'rb') as husky, open(
'./cats.zip', 'rb') as cats:
model = visual_recognition.create_classifier(
'dogs',
positive_examples={'beagle': beagle, 'goldenretriever': goldenretriever, 'husky': husky},
negative_examples=cats).get_result()
print(json.dumps(model, indent=2))
Make sure that you have the set the service url correctly. The endpoint should match the region in which you have created your visual recognition service. You can verify what the url should be, as it will be available in the same place you get your API key from.
Thinking about this as I wrote the previous paragraph, I realise that as you are new to Watson Visual Recognition, you may not have created an instance of the service or generated an API key. As the service has been deprecated, you may not be able to do so. If this is the case, then I am afraid you won't be able to make use of the service.
Upvotes: 0