Onychosis (commonly referred to as nail disease) is a disease or deformity of the nail. Although the nail is a structure produced by the skin and is a skin appendage, nail diseases have a distinct classification as they have their own signs and symptoms which may relate to other medical conditions. Some nail conditions that show signs of infection or inflammation may require medical assistance. Nail disorders are a common reason for dermatologic consultation. They are assessed by clinical inspection, dermatoscopy, diagnostic imaging, microbiological (including mycological) testing, and histopathological examination. Some 10% of the overall population suffers from onychomycosis, with a point prevalence of around 15%. High-risk groups for nail disorders include diabetics, dialysis patients, transplant recipients, and cancer patients. Malignant tumours of the nails are often not correctly diagnosed at first. For subungual melanoma, the meantime from the initial symptom to the correct diagnosis is approximately 2 years; this delay is partly responsible for the low 10-year survival rate of only 43%. The most common reason for such a delay is due to lack of dermatologists and medical scanning facilities in tier 2, tier 3 cities, small towns and villages.
For the purposes of demonstration, we are presently focusing on classifying nails into four different classes: acute paronychia, beaus lines, chronic paronychia and clubbing. We have made a handheld device that uses a Raspberry Pi 4B (we intended to use the RPi 3A+, but couldn't get it due to the current semiconductor crisis☹️!), a 7inch Raspberry Pi Touchscreen and a Logitech webcam. So the user will just give power to the RPi and it will automatically boot and display our webpage wherein the user will only have to put the finger in front of the webcam and the results will be displayed by the algorithm.
What is under the hood?We're using Edge Impulse Studio to build our ML infrastructure. We've used the dataset provided by Dermnet (it is a New Zealand-based clinical resource website about dermatology and skin conditions. Its founder and current editor-in-chief is dermatologist and Adjunct Associate Professor Amanda Oakley.) to create our model.
You can find out the dataset we've used in the repository linked at the end of this article.
Following is the train/test split ratio we have used in the development of our model:
And here are the blocks we've used for our impulse design step:
Next up, we've used the Transfer Learning block with MobileNet V2 96X96 0.35 for the creation of our ML model. Now to put it simply, Transfer Learning is a way a model trained on one task is repurposed on a second, related task as an optimization that allows rapid progress when modelling the second task.
We've used the MobileNet V2 96X96 0.35 model as to crop the image and focus on the nail rather than on its surroundings, moreover, it helps in increasing accuracy along with a bit faster processing time.
Also, I've used the famous EON Tuner for getting an accuracy of about 87% on my model.
STEP 1: Get all the required stuff namely the RPi 4B, 7inch touchscreen display and an RPi Camera/any 720p or greater webcam. Also, don't forget to get a case for the display (you can also 3D print if you want!).
STEP2: Assemble the RPi and the display in the case as shown below.
STEP 3: Flash the SD card with RPi OS image from here, and plug in the webcam and the power supply in the RPi.
STEP 4: We're not using any python script or anything else to run the model on the device, but instead to allow this to run on almost any SBC we're using EI's built-in smartphone classifier to run on the device.
So for this project, we will be using Edge Impulse Studio project API keys along with EI's built-in classifier website from the Deployment page.
For retrieving the API key click on the Dashboard tab and move to the Keys section. Now copy the API key from the Studio and paste it to a notepad or somewhere you can revisit in the future.
STEP 5: Now, open the terminal and type the following lines of code:
$ cp /etc/xdg/lxsession/LXDE-pi/autostart ~/.config/lxsession/LXDE-pi/
$ nano ~/.config/lxsession/LXDE-pi/autostart
Now edit the file and put the following:
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash point-rpi chromium --start https://smartphone.edgeimpulse.com/classifier.html?apiKey=[ENTER YOUR API KEY HERE]
Then do a sudo reboot now
, and the device will restart itself.
Once the restart happens, you will get to see that Chromium will open up itself and will display the requested webpage on it.
Once the webpage loads completely it will ask you for camera permissions, which you need to accept.
Finally, it will display the live camera view along with certain results as shown below.
So, that was it. This is how I built this open source Onychosis detector device that can classify a nail with up to 4 different disease labels.
The project is out on GitHub already, feel free to explore it and let me know in the comments what would you wanna add to this that would be helpful for the community?
Peace,
Arijit!
😉
Comments