Sushrut / app.py
deepjyoti7147's picture
Update app.py
961de29
Raw History Blame Contribute Delete
6.04 kB
import streamlit as st
import cv2
import numpy as np
from PIL import Image,ImageDraw
from tensorflow.keras.models import load_model
import tensorflow as tf
# Load the model
model = tf.keras.models.load_model('./Finetune.h5')
def make_image_circular(image_path, size):
img = Image.open(image_path)
img = img.resize((size, size))
height, width = img.size
lum_img = Image.new('L', [height, width], 0)
draw = ImageDraw.Draw(lum_img)
draw.pieslice([(0, 0), (height, width)], 0, 360, fill=255, outline="white")
img_arr = np.array(img)
lum_img_arr = np.array(lum_img)
final_img_arr = np.dstack((img_arr, lum_img_arr))
final_img = Image.fromarray(final_img_arr)
return final_img
# Function to analyze the image
def analyze_image(image):
img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
img = cv2.resize(img, (224, 224))
img = np.expand_dims(img, axis=0)
img = img / 255.0
predictions = model.predict(img)
class_labels = ['Benign', 'Malignant']
predicted_class = class_labels[np.argmax(predictions)]
probability = np.max(predictions)
return predicted_class, probability
# Main function
def main():
# Project description
st.title("Medical Image Analysis")
st.write("This is a demo of the app. Upload an Image and tap analyse.")
st.write("Currently it can classify images into Benign and Malignant")
# Image classification
uploaded_file = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
if st.button("Classify"):
predicted_class, probability = analyze_image(image)
st.write(f"Predicted Class: {predicted_class}")
st.write(f"Probability: {probability:.4f}")
# Intro and current problem
st.header("Introduction and Current Problem")
st.write("Gallbladder cancer is a deadly disease that often goes undetected until later stages, leading to poor prognosis. Additionally, gallbladder stones are a common condition that can cause swelling of the gallbladder wall, mimicking malignancy. This creates a challenge for accurate diagnosis using ultrasound scans. In this project, we aim to utilize deep learning techniques to distinguish between edema caused by gallbladder stones and malignancy in gallbladder images obtained from ultrasound scans (UGS).")
st.write("The current problem lies in accurately differentiating between edema caused by gallbladder stones and malignancy in ultrasound scans. The thickness of the gallbladder wall, an important diagnostic parameter, is often difficult to discern accurately by human interpretation alone, potentially resulting in misdiagnosis and delayed treatment.")
# Solution approach
st.header("Solution Approach")
st.write("To address this problem, we propose utilizing deep learning techniques. Specifically, we will employ the Inception v3 architecture, a convolutional neural network (CNN) model, combined with Local Binary Pattern (LBP) analysis. By training the model on a dataset of annotated ultrasound images, we aim to develop a predictive model that can accurately classify images as either edema caused by gallbladder stones or malignancy.")
# Tech stack
st.header("Tech Stack")
st.write("The tech stack for this project includes deep learning frameworks such as TensorFlow or PyTorch for implementing the Inception v3 model. Additionally, we will incorporate LBP analysis to capture texture information from the ultrasound images. Python will be used as the primary programming language, along with relevant libraries for image processing and machine learning.")
# Conclusion
st.header("Conclusion")
st.write("By leveraging deep learning and image analysis techniques, we strive to enhance the accuracy and efficiency of diagnosing gallbladder conditions. The proposed model has the potential to aid healthcare professionals in distinguishing between edema and malignancy in gallbladder ultrasound scans, enabling early detection and appropriate treatment, thereby improving patient outcomes.")
# Project Team
st.header("Project Team")
# Person 1
st.subheader("Deepjyoti Purkayastha: Lead Developer(ML)")
person1_image = make_image_circular("./Images/Person1.jpg", size=100)
st.image(person1_image, caption="From Narula Institute of Technology", use_column_width=False)
# Person 2
st.subheader("Tamojit Ray: Backend Developer")
person1_image = make_image_circular("./Images/Person2.jpeg", size=100)
st.image(person1_image, caption="From Narula Institute of Technology", use_column_width=False)
# Person 3
st.subheader("Arijit Roy: Frontend Developer")
person1_image = make_image_circular("./Images/NotAvailable.jpg", size=100)
st.image(person1_image, caption="From Narula Institute of Technology", use_column_width=False)
# Person 4
st.subheader("Subrat Kumar Sahoo: Medical Adviser")
person1_image = make_image_circular("./Images/Person3.jpg", size=100)
st.image(person1_image, caption="From Bardwan Medical College", use_column_width=False)
# Person 5
st.subheader("Kushi Panday: Medical Adviser")
person1_image = make_image_circular("./Images/NotAvailable.jpg", size=100)
st.image(person1_image, caption="From Bardwan Medical College", use_column_width=False)
# Person 6
st.subheader("Dr. Somya Banarjee: Mentor")
person1_image = make_image_circular("./Images/Person6.jpg", size=100)
st.image(person1_image, caption="From Bardwan Medical College", use_column_width=False)
# Person 7
st.subheader("Pushpit Roy: Mentor")
person1_image = make_image_circular("./Images/Person7.jpg", size=100)
st.image(person1_image, caption="From Narula Institute of Technology", use_column_width=False)
if __name__ == "__main__":
main()