Let me begin with the following note: We built the model as described below, but then we encountered an error which caused all the images to be classified as “pneumonia”. In the same time we had an opportunity to work closely with Oracle AI Services development team who have responded instantly and successfully removed the bug. And here are the results.
Train
The process of training the model is code free. Similarly as described in one of my previous blog posts, we needed a new custom project. Project acts as a container which can contain several models we created.
There is a wizard that helps users to create a new one. The wizard is executed in three steps.
In the first step, basic parameters are set, such as the type of the model. In our case Image Classification is chosen.
Then we need to specify the training data. We can use an existing dataset which can be sourced from Data Labeling Service or from Object Storage. In our example, we are using originally unlabeled dataset which we labeld using Data Labeling Service.
There will be (I hope) enough time to write about this topic in a separate blog post, but for now let’s just say that images can be labeled manually (one by one) or programatically (for bulk labeling). We are dealing with thousands of images, so we used the template that is available in Oracle’s documentation with minor adjustments.
In the second step, basically we just need to set model training duration. In our exercise we selected the recommended option, that is up to 24 hours.And the last step is just confirmation and execution.
In the end, the model training in our case ran for about 5 hours. During the process, progress can be monitored in a console.
Evaluate and Use
After the model is created, the basic statistics are displayed and you can instantly start using it.
Closer look at the Training metrics reveals that model is performing rather well:
To test how the model works, we can upload some images and test it. Our images are stored in Object Storage and we can retrieve an URL from there:
And here is the prognosis:
Access
The UI which we use is a standard, web-based, user console. However, main use case will be programatically using REST API. And this is how request should be made:
"compartmentId": "ocid1.compartment.oc1…...",
"image": {
"source": "OBJECT_STORAGE",
"namespaceName": “...",
"bucketName": "Pneumonia",
"objectName": "test/PNEUMONIA/person100_bacteria_475.jpeg"
},
"features": [
{
"modelId": "ocid1.aivisionmodel.oc1.e.. ..a",
"featureType": "IMAGE_CLASSIFICATION",
"maxResults": 5
}
]
}
and the response is like this:
"imageObjects": null,
"labels": [
{
"name": "PNEUMONIA",
"confidence": 0.99664
},
{
"name": "NORMAL",
"confidence": 0.003360053
}
],
"ontologyClasses": [
{
"name": "PNEUMONIA",
"parentNames": [],
"synonymNames": []
},
{
"name": "NORMAL",
"parentNames": [],
"synonymNames": []
}
],
"imageText": null,
"imageClassificationModelVersion": "version",
"objectDetectionModelVersion": null,
"textDetectionModelVersion": null,
"errors": []
}
Conclusion
In this simple example, we can see that codeless Image Classification using AI Vision service can perform. And it can perform well. It is definitely an excellent news for those who are not so skilled in Machine Learning and would like to utilise new modern tools such as Oracle AI Vision.
It is easy, it is fast, it can provide good results. But of course, please use it with caution and don’t forget it is more or less like a box of chocolates (for now):
And afterall at the end, chocolates usually turn out to be good, aren’t they?