From 206b5db2355c8ed301387f479ee7ce3517848478 Mon Sep 17 00:00:00 2001 From: Amey Muke Date: Sun, 30 Jul 2023 09:47:25 +0530 Subject: [PATCH 1/3] Done Submission --- README.md | 36 +++++++++++++++++++++++------ model.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 model.py diff --git a/README.md b/README.md index 9d3f4a24..f6a4b952 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,40 @@ ## README.md must consist of the following information: -#### Team Name - -#### Problem Statement - -#### Team Leader Email - +#### Team Name - Team Titans +#### Problem Statement - Knee OsteoArtheritis AI Report WebApp +#### Team Leader Email - vaidehikuite.fd@gmail.com ## A Brief of the Prototype: - This section must include UML Diagrams and prototype description + Osteoarthritis is a joint disease impacting millions worldwide +WHO is 2019 said that there are 528 million people worldwide living. +In India, about 150 million people have osteoarthritis,while 32.5 million in United states suffer from it. +They go through a lot of pain like Joint pain, morning stiffness, pain during movement, pain at rest + +As Osteoarthritis can you detected through X-Rays it can be also caused due to many other factors. +The combination of X-rays and related factors such as obesity, age, height, bone density can help us detect +Product Solution (1-3 Slides) +What the machine does it takes the X-ray input from the user and puts it through the model after that the model categories the X-ray as the severity of the patient +After the process id done it combines it with other factors like the weight, age, height, bone density which gives us end results also by using OpenAI we created a prompt where when user puts all this info it gives them suggestions about the Osteoarthritis. +Differentiations (USPs) +Considering various factors that can also lead to Osteoarthritis and create accurate results. +Higher accurate results +Prompt where you can get tailored solution according to the severity of Osteoarthritis + +User Interface => User Uploads the X-Rays => User gets seventy grading => User is asked with more details such as gender, age , weights => all parameters along with it gets passed => a report is generated + + ## Tech Stack: - List Down all technologies used to Build the prototype + TensorFLow + Gradio + OpenAI ## Step-by-Step Code Execution Instructions: - This Section must contain a set of instructions required to clone and run the prototype so that it can be tested and deeply analyzed + Run the Model step by step no other thing needed ## What I Learned: - Write about the biggest learning you had while developing the prototype + There are many people who suffer with this and with this we can help people out also with medical we need to consider lots of aspects and overall view + +## Link to download the model: + https://drive.google.com/file/d/1t6XblfNhaDe4RskXoY_Apha6csvVReno/view?usp=sharing \ No newline at end of file diff --git a/model.py b/model.py new file mode 100644 index 00000000..df4dfc13 --- /dev/null +++ b/model.py @@ -0,0 +1,69 @@ +import numpy as np +import pandas as pd +import cv2 as cv +import matplotlib.pyplot as plt +import os +import pickle +import tensorflow as tf +from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, BatchNormalization +from tensorflow.keras.preprocessing.image import ImageDataGenerator +from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping, ReduceLROnPlateau +from keras.models import Model +from sklearn.preprocessing import LabelBinarizer +save_model = tf.keras.models.load_model("Best_DenseNet201.h5",compile=False) + + +from PIL import Image +import gradio as gr +import numpy as np +from skimage import transform +from tensorflow.keras.utils import load_img, img_to_array +from keras.preprocessing.image import ImageDataGenerator +from keras.applications.vgg16 import preprocess_input + +def load(filename): + my_image = load_img(filename, target_size=(224, 224)) + + #preprocess the image + my_image = img_to_array(my_image) + my_image = my_image.reshape((1, my_image.shape[0], my_image.shape[1], my_image.shape[2])) + my_image = preprocess_input(my_image) + + #make the prediction + prediction = save_model.predict(my_image) + print(prediction) + prediction = tf.argmax(tf.nn.softmax(prediction), 1) + return "Serverity grading:- " + str(int(tf.get_static_value(prediction).item())) + + +import openai + +def noob_wrapper(gender, obesity, severity_grading_score, age): + + openai.api_key = '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' + + prompt = "You are a arthritis doctor and your patient has osteoarthritis." + + messages = [ {"role": "system", "content": + prompt} ] + while True: + message = f"Severity grade my osteoarthritis is {severity_grading_score} and his gender is {gender} and his age is {age} and his obesity is {obesity}. Renerate a report on this." + if message: + messages.append( + {"role": "user", "content": message}, + ) + chat = openai.ChatCompletion.create( + model="gpt-3.5-turbo", messages=messages + ) + reply = chat.choices[0].message.content + print(f"ChatGPT: {reply}") + return reply + + + +demo = gr.Interface(fn=noob_wrapper, inputs=[gr.Radio(["Male", "Female", "Undefined"], label="Gender"), gr.Radio(["Yes", "No"], label="Obesity"),gr.Textbox(placeholder="Enter Severity Grading Score"),gr.Textbox(placeholder="Enter Your Age")], outputs="text") +gradio = gr.Interface(fn=load,inputs=gr.Image(type="filepath"),outputs=gr.Label()) + +demo2 = gr.TabbedInterface([gradio, demo], ["Severity Grading", "Report Generation"]) + +demo2.launch() \ No newline at end of file From 5f5b9afddc430918822b7e83bd44cdd398902b2f Mon Sep 17 00:00:00 2001 From: Amey Muke Date: Sun, 30 Jul 2023 10:08:41 +0530 Subject: [PATCH 2/3] Fixed Some Bugs --- .gitignore | 1 + model.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5737de1d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Apikey.py diff --git a/model.py b/model.py index df4dfc13..8e29cecc 100644 --- a/model.py +++ b/model.py @@ -37,10 +37,11 @@ def load(filename): import openai +from Apikey import OPENAI_API_KEY def noob_wrapper(gender, obesity, severity_grading_score, age): - openai.api_key = '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' + openai.api_key = OPENAI_API_KEY prompt = "You are a arthritis doctor and your patient has osteoarthritis." From d655872aa177d2d7b7d0070e5349a645fd4f62cb Mon Sep 17 00:00:00 2001 From: Perfect_7613 <78261311+perfect7613@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:15:32 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f6a4b952..d926e4e4 100644 --- a/README.md +++ b/README.md @@ -45,4 +45,7 @@ User Interface => User Uploads the X-Rays => User gets seventy grading => User i There are many people who suffer with this and with this we can help people out also with medical we need to consider lots of aspects and overall view ## Link to download the model: - https://drive.google.com/file/d/1t6XblfNhaDe4RskXoY_Apha6csvVReno/view?usp=sharing \ No newline at end of file + https://drive.google.com/file/d/1t6XblfNhaDe4RskXoY_Apha6csvVReno/view?usp=sharing + +## Demo Video of the System + https://drive.google.com/file/d/1sm1Q5RLMmI3C8pt_nhR8-xKNEDvmaEba/view?usp=drive_link