The capabilities of Computer Vision (CV) models are progressing by leaps and bounds fostering more and more adoption across a number of industries. One of these industries is the healthcare sector where computer vision is being used as a powerful diagnostic imaging tool to provide potential life saving results for patients. These CV models can help diagnose diseases, monitor treatments, and improve outcomes for patients. Analyzing images from various sources, such as X-rays, MRI scans, ultrasound, or optical cameras, they can detect anomalies, measure features, segment regions, and classify conditions.
In this post, we will demonstrate putting a computer vision model into production that detects mitochondria from high resolution images.
For this example we will be using a high resolution 1536 x 2048 image that is broken down into “patches” of 256x256 images that can be quickly analyzed.
Mitochondria are known as the “powerhouse” of the cell, and having a healthy amount of mitochondria indicates that a patient has enough energy to live a healthy life, or may have underlying issues that a doctor can check for.
Scanning high resolution images of patient cells can be used to count how many mitochondria a patient has, but the process is laborious. The following ML Model is trained to examine an image of cells, then detect which structures are mitochondria. This is used to speed up the process of testing patients and determining next steps.
Before moving on, you can step through this computer vision deployment exercise by downloading the Wallaroo Community Edition and the Health Diagnostic Imaging Tutorial.
After loading the necessary dependencies and libraries the next step is to establish a connection to the Wallaroo Client. The Python library is included in the Wallaroo install and available through the Jupyter Hub interface provided with your Wallaroo environment.
We will create a workspace to manage our pipeline and models. The following variables will set the name of our sample workspace then set it as the current workspace.
In the next step we will:
- Upload our model.
- Apply it as a step in our pipeline.
- Create a pipeline deployment with enough memory to perform the inferences.
- Deploy the pipeline
It’s important to point out that our model is deployed in less than 45 seconds which can take days and weeks normally with other ML tools.
The next step is to process the image into a numpy array that the model is trained to detect from.
We start by retrieving all the patch images from a recorded time series tiff recorded on one of our microscopes.
Randomly we will retrieve a 256x256 patch image and use it to do our semantic segmentation prediction.
We’ll then convert it into a numpy array and insert into a DataFrame for a single inference.
The following helper function loadImageAndConvertTiff
is used to convert the image into a numpy, then insert that into the DataFrame. This allows a later command to take the randomly grabbed image and perform the process on other images.
We will now perform our inferences and display the results. This results in a predicted mask showing us where the mitochondria cells are located.
- The first image is the input image.
- The 2nd image is the ground truth. The mask was created by a human who identified the mitochondria cells in the input image
- The 3rd image is the predicted mask after running inference on the Wallaroo pipeline.
We’ll perform this 10 times to show how quickly the inferences can be submitted.
Finally we will undeploy our pipeline and give the resources back to the instance.
This is just one example of how to use Machine Learning to overcome difficulties to deploy and serve CV models without complex technical infrastructure bottlenecks or requiring data engineering expertise to imaging the data, and to use computer vision models for advanced object detection, object classification for health diagnostic imaging in areas of radiology, pathology, cell-imaging.
As mentioned above you can try this yourself by downloading the Wallaroo Community Edition and the Health Diagnostic Imaging Tutorial.
Top comments (0)