adityamittl / Delta-Diagnose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Header

Delta Diagnose 2.2

πŸ†• Updates

Added a new UI built using Streamlit.

Streamlit UI

To run this file, go to Streamlit UI folder, install the requirements, fire up your terminal and type streamlit run '.\Delta Diagnose.py'

Delta Diagnose 2.1

πŸ†• Updates

  • Used Quantization Aware Training to reduce the Trained Model size from 30.1 MB to 2.41 MB (92% reduction in Size)
  • Further reduced the request serving time from 1.54 seconds earlier to less than 1 second now (50% reduction in serving time)
  • Added a new way to interact with the API
API.mp4

Delta Diagnose 2.0

Every hackathon, we enjoy developing new projects, but many previously built terrific projects with the potential to become something great in the future are abandoned in the early stages of development in the process. So we decided to spend this weekend working on a new version of Delta Diagnose with lots of new features and a revamped UI. You can know more about the previous version from here.

πŸ’‘ Inspiration

The Delta variant of COVID-19 arrived in India in March 2021. It led to the deaths of 270,000 individuals in three months, more than twice the number we saw in the entire year of 2020.
The Delta strain has a higher affinity for lung tissues than other strains, making it more lethal.
The same mutation has now been discovered in other parts of the world. We wanted to aid the people in these countries, thus we created Delta Diagnose.
Viral Pneumonia, a condition with identical symptoms, has made identifying COVID patients even more challenging.

πŸ’» What it does

Delta Diagnose aims to analyze Chest MRI Images and classify them as COVID-19, Viral Pneumonia, and Normal. It can not only assist doctors but can also be directly used by the patients to self-diagnose (although we suggest confirming the results with doctors).

πŸ†• Updates

1. Model Changes

  • Added 1704 new images to the training data (678% increase in training data)
  • Added 119 new images to the test data (180% increase in test data)
  • Compared to the last time, constructed the model from scratch (was using Transfer Learning previously)
  • Increased the accuracy from 97% to 99%
  • Significantly reduced the saved model size from 169 MB to 30.1 MB (83% reduction in Size)

2. API Changes

  • Fixed a Bug: When deployed on Heroku, the system automatically shuts down after 30 minutes of inactivity. When restarted, the app should be up and running within 60 seconds or Heroku would simply serve the request. Due to large model size, the system would not fully load and would result in an error for the first request sent after restarting the system.
  • Since we reduced the model size in previous step, this bug was automatically resolved
  • Used FastAPI instead of Flask
  • Significantly reduced the request serving time from 5 seconds earlier to 1.54 seconds now (69.2% reduction in serving time)

3. UI changes

  • Revamped the complete UI
  • Added Login and Signup Page
  • Integrated Twillio for OTP verification
  • Elevated the User Experience

βš™οΈ How it works

  • User needs to Login/Signup
  • User needs to upload a Chest MRI Image >
  • We would process the image and return the result

πŸ”¨ Tech Stack

Python Django HTML5 CSS3 JavaScript Bootstrap
Tensorflow Keras OpenCV FastAPI

🧠 Challenges we ran into

  • The biggest challenge was to manage the size of the API. If the size increases by 300 MB, Heroku takes a lot of time to boot up the virtual machine which was not an ideal scenario. In the previous version, the size was 493 MB which was reduced to 318 MB after retraining the model and switching to FastAPI. At this moment we were drained of energy and couldn't think of more ways to reduce that extra 18 MB. Then the last thing we decided to try was to find a version of big libraries such as Tensorflow and OpenCV which is as small in size as possible and as recent as possible. Finally we were able to pack it up in a size of 283 MB with all the required libraries and everything.
  • Another thing that we tried was Quantization Aware Training but doing that reduced the accuracy of our model to 65% so it was not really something we could put into production.

πŸ… Accomplishments that we're proud of

This is actually the first time we have achieved an accuracy of 99% on model that we trained from scratch which is really a stat we would love to boast about.

πŸ“– What we learned

  • We learned how to use FastAPI and thanks to awesome documentation, that process was seamless.
  • We learned how to reduce slug size of your project to increase performance.
  • We learned about Quantization Aware training to reduce the size of the model and make it accessible for small devices.
  • We also leared how to use Twillio for OTP Authentication

πŸš€ What's next for Delta Diagnose

All the stats we are boasting about are limited to the small amount of data we have. We would love to see how it performs on the real world data by taking this project to a specialized doctor.

Installing and running

Model API

Send a POST request on URL http://delta-diagnose-api.herokuapp.com/ with JSON file containing URL of image to classify as a Parameter

Sample JSON File

{
  "url" : "https://i.ibb.co/FBSztPS/0120.jpg"
}

Sample Response

{
  "class":"viral_pneumonia",
  "class_probability":99.93
}

GUI Version

Jump over to the UI folder and run

pip install -r requirements.txt
python manage.py runserver

About

License:MIT License


Languages

Language:Jupyter Notebook 86.1%Language:Python 9.2%Language:HTML 4.6%Language:Procfile 0.0%