Advancing Healthcare Image Analysis on OCI - Diabetic Retinopathy

May 25, 2022 | 8 minute read
Subhan Chaudry
Cloud Engineer, Enterprise Growth Team
Text Size 100%:

Retina Image Analysis


Medical image classification is quickly becoming one of the most powerful tools for clinical providers to use in the detection of medical conditions. Through classifying medical images, providers can become more effective in clinical care and suggesting relevant treatment options. However, it has become an increasingly complex task for data scientists in healthcare organizations to store datasets, annotate records, and build efficient machine learning models to classify images. 

Oracle Cloud Infrastructure (OCI) can help healthcare organizations execute their artificial intelligence and machine learning initiatives with its comprehensive platform for building image classification models. OCI’s Object Storage, Data Labeling, and Data Science services make it simple for data scientists to centralize development without the need to rely on isolated third-party tools. 

Detection of Diabetic Retinopathy

In this post, I will be walking through step-by-step how I leveraged these OCI services to detect the presence of diabetic retinopathy from retina images. Diabetic retinopathy (DR) is the most common diabetic eye disease and one of the leading causes of blindness. According to the International Diabetes Federation (IDF), it affects an estimated 103.12 million adults worldwide as of 2020. After 15 years of diabetes, 98% of those with type 1 diabetes and 78% of those with type 2 diabetes have retinal damage. 

Currently, detecting DR is a time-consuming and manual process that requires a trained clinician to examine and evaluate digital color fundus photographs of the retina. By the time human readers submit their reviews, often a day or two later, the delayed results lead to lost follow up, miscommunication, and delayed treatment. It has long been clear that there is an immediate need for an automated way to screen diabetic retinopathy. With OCI, we demonstrate the ease of using our platform to build automated detection models for diabetic retinopathy and any other type of medical image analysis.

Overview of Diabetic Retinopathy Dataset

For this use case, I will be using a dataset of 35,126 high-resolution retina images provided by EyePACS. These images were taken under a variety of imaging conditions with both a left and right field for each patient. A clinician has rated the presence of diabetic retinopathy in each image on a scale of 0 to 4, according to the following scale: 0 – No DR, 1 – Mild, 2 – Moderate, 3 – Severe, 4 – Proliferative DR. These scores are provided in a CSV file that contains the image name and corresponding score.

You can access this entire dataset with more details on Kaggle.

OCI Object Storage to Store Medical Imaging Datasets Securely

OCI’s Object Storage service is a high-performance storage platform that offers reliable and cost-effective data durability. It can store an unlimited amount of unstructured data of any content type with the ability to restrict access for any sensitive information. 

To use Object Storage, a user simply needs to navigate to the “Object Storage & Archive Storage” screen on the OCI console and then create a bucket as seen below. 

Creating a bucket on the OCI console

As this is a large dataset, I opted to utilize Oracle’s command line tools to upload the dataset into my Object Storage bucket. It is important that you setup Oracle CLI on your computer prior to any usage. You can find steps to install it in our documentation.

I am utilizing a MacBook and ran this command in the terminal to begin the upload of all the dataset files: 

oci os object bulk-upload -ns [namespace] -bn [object_storage_bucket_ocid] --src-dir [location_of_images] --content-type image/jpeg

The upload will take a few minutes to complete, but then you will see the list of files successfully uploaded to your bucket on your OCI console. 

List of retina objects uploaded to an OCI bucket

OCI Data Labeling for Rapidly Applying Medical Annotations and Labels

OCI Data Labeling is a service designed to build labeled datasets for training artificial intelligence and machine learning models. Users can quickly assemble data, create/browse datasets, and apply labels to records via the OCI console or public APIs. 

When building a data labeling dataset, a user navigates to our “Data Labeling” screen on the OCI console. They can then create a dataset, enter any descriptions/instructions, format, and select the annotation class for their use case. I went with images for the format and the Single Label annotation class since each retina image will only have one corresponding label.

Creating a dataset in OCI DLS

A user can create and add files by directly uploading local files or selecting an Object Storage bucket from which to generate dataset records. In our use case, we already uploaded our files to Object Storage and can choose the corresponding bucket that contains our retina images. Note, if you decide to upload files then it will redirect you to create an Object Storage bucket like we did earlier.

Selecting the Object Storage bucket for your DLS dataset images in the OCI Console

We then simply need to add our list of labels for the dataset and can continue with creating the dataset. I created a label set of numbers from 0 to 4 to represent the severity of diabetic retinopathy, but you can make the labels more descriptive if needed. These labels will later be attached to each of the images in your dataset to help with training an AI Vision model. 

Adding labels to your DLS dataset in the OCI console

Given the size of our dataset, it will take a few minutes to generate all the image records. Once generated, you will see a list of all the data records and can click into a record to apply a label. In the record view, you see the image and the list of labels on the right side. You can easily select the appropriate label and save the record details. There are also some menu options that you can select to zoom in/out and adjust different image parameters to help with your analysis.

Viewing a record's details in an OCI DLS dataset

Considering the size of the diabetic retinopathy dataset, I decided to write a python script that would make calls to the Data Labeling APIs. My script automatically labeled the records based on the references in the CSV file that contained the image name and diabetic retinopathy score. With multi-threading, I labeled the entire dataset in just a few minutes, and it was ready to be used for building an AI Vision model. You can find a link to my data labeling python script on GitHub.

The Data Labeling Service documentation is also provided at the end of this blog if you would like to create your own script and adjust different parameters for how the record will be labeled. 

OCI Vision to Generate Object Classification Models At-Scale

OCI Vision is an AI service for performing deep-learning-based image analysis at scale in the cloud. Users can automatically train custom vision models with their own labeled data without any need for machine learning expertise. 

To access OCI Vision, a user navigates to our “Vision” screen and can click “Projects” under Custom models to build their own image analysis model. Users can also utilize the pre-built image classification, object detection, and document AI models. 

On the projects page, a user needs to create a project to store all their models. After creation of a project, they can click into it and then create a model. They will choose between Image Classification and Object Detection models and then choose where the training data will be coming from. We chose Image Classification and selected the labeled dataset from the OCI Data Labeling Service. 

Selecting model type and training data sources for an OCI AI Vision model

Then, just enter in a few basic details about your model and determine what the training duration should be. I went with Recommended training as it will provide the highest level of accuracy for our model. A user can also set their own custom duration if they want the model to run for a specific amount of time but running the model for too long will not provide significant changes in accuracy. 

Entering model details and training duration for an OCI AI Vision model

The model creation can take up to 24 hours to complete. It will typically select 10% of your dataset to use for testing the model. Once finished, you can view statistics for the model performance like precision, recall, and the F1 score. You can also click the Training metrics tab to see statistics based on the specific label. 

To test the model, simply upload an image in the Analyze section and you can view the results returned by the model. Below we can see that our model was able to accurately classify image 10_left.jpeg with “0 – No DR” having the highest confidence. My final model performed well in determining whether or not there was any presence of diabetic retinopathy with an F1 score of 85.84%.

Analyzing an AI Vision model on the OCI console

Developers in a healthcare organization can implement these models into their applications and build workflows to process images by studying the request and response results. Through following the AI Vision documentation, these models can be deployed for real-time use anywhere an organization needs them. In terms of outcomes, clinicians can spend more time building out treatment plans and engaging directly with customers rather than time-consuming examination of these images.


Oracle Cloud Infrastructure is built to help healthcare organizations execute on their medical image analysis initiatives and provide the platform to centralize and simplify development. Diabetic Retinopathy is just one of infinite imaging projects that can be built with Oracle’s comprehensive platform, and we’re excited to keep working with our customers who are paving the way forward in medical imaging innovation. 

Please check out some other innovative projects from our healthcare customers on OCI. If you’d like to try out our cloud, start with a 30-day free trial and build out solutions with OCI’s services. 

To learn more about our services enabling medical image analysis, check out the following resources:

Reach out to for questions on this use case or how OCI can help healthcare organizations achieve medical image analysis at-scale. 

Subhan Chaudry

Cloud Engineer, Enterprise Growth Team

Previous Post

Training a Machine Learning Model on Time-Series Telemetry to Optimize Manufacturing

Joe Hahn | 6 min read

Next Post

How embedded AI is making analysis more actionable

John Menhinick | 4 min read