File size: 5,150 Bytes
25515ea
 
 
417adf8
25515ea
 
 
 
 
 
 
 
 
e4afced
25515ea
5a4e86d
e4afced
 
25515ea
832b4a4
25515ea
e4afced
25515ea
832b4a4
25515ea
e4afced
25515ea
832b4a4
25515ea
e4afced
25515ea
832b4a4
25515ea
e4afced
25515ea
832b4a4
25515ea
e4afced
25515ea
832b4a4
25515ea
 
 
 
 
 
 
09986f2
25515ea
 
09986f2
 
25515ea
 
 
 
 
 
 
832b4a4
6e9a95f
832b4a4
6e9a95f
 
832b4a4
6e9a95f
 
832b4a4
 
6e9a95f
832b4a4
6e9a95f
 
 
25515ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import tensorflow as tf
import cv2
import numpy as np
import streamlit as st

def classify(img):
    im = img
    lt = ["other","Bone","Brain","eye","kidney","chest","skin"] 
    im = cv2.resize(im,(52,52))
    model = tf.keras.models.load_model("all-in-one.h5",compile=False)
    result = model.predict(np.array([im]))
    a = np.argmax(result)
    c=""
    
    if a==0:
        st.write('________________________________________________')
        return "Provide the medical Imaging of the mentioned categories"
        # st.write('________________________________________________')
    if a==1:
        st.write('________________________________________________')
        c = bone_net(im)
        # st.write('________________________________________________')
    if a==2:
        st.write('________________________________________________')
        c = brain_net(im)
        # st.write('________________________________________________')
    if a==3:
        st.write('________________________________________________')
        c = Eye_net(im)
        # st.write('________________________________________________')
    if a==4:
        st.write('________________________________________________')
        c = kidney_net(im)
        # st.write('________________________________________________')
    if a==5:
        st.write('________________________________________________')
        c = chest_net(im)
        # st.write('________________________________________________')
    if a==6:
        st.write('________________________________________________')
        c = skin_net(im)
    return c



def bone_net(img):
    # img = cv2.resize(img,(224,224))
    lt = ["Normal",'Fractured']
    model = tf.keras.models.load_model("fracture.h5",compile=False)
    result = model.predict(np.array([img]))
    ans = np.argmax(result)
    return lt[ans]

def brain_net(img):
    lt = ['pituitary', 'notumor', 'meningioma', 'glioma']
    # img = cv2.resize(img,(52,52))
    model = tf.keras.models.load_model("brain.h5",compile=False)
    result = model.predict(np.array([img]))
    ans = np.argmax(result)
    b = ""
    c = ""
    if ans==3:
        b = f"Glioma: Can range from low-grade (mild) to high-grade (severe)."
        c = "\n\nAvoid activities that could cause head injury, such as contact sports.\nTake steps to manage seizures, which can be a common symptom of gliomas.\nAvoid exposure to radiation, as this can increase the risk of developing a glioma.\nTake steps to reduce stress, which can exacerbate symptoms and affect overall health.\nWork with a healthcare provider to manage any other underlying medical conditions that could impact treatment."
    if ans==2:
        b=f"Meningioma: Most are low-grade."
        c = "\n\nAvoid activities that could cause head injury, such as contact sports.\nWork with a healthcare provider to manage any underlying medical conditions, such as high blood pressure, that could impact treatment.\nBe aware of potential symptoms, such as headaches or changes in vision, and seek medical attention promptly if they occur.\nTake steps to reduce stress, which can exacerbate symptoms and affect overall health.\nFollow a healthy lifestyle, including a balanced diet, regular exercise, and adequate sleep."
    if ans==1:
        b = "No tumor: N/A \n\n Enjoy the Life "
        c = ""
    if ans==0:
        b = f"Pituitary: Can be either benign or malignant."
        c = "\n\n Work with a healthcare provider to manage any underlying medical conditions, such as diabetes, that could impact treatment.\nBe aware of potential symptoms, such as headaches or changes in vision, and seek medical attention promptly if they occur.\nFollow a healthy lifestyle, including a balanced diet, regular exercise, and adequate sleep.\nTake steps to manage any hormonal imbalances that may result from the tumor.\nAvoid exposure to radiation, as this can increase the risk of developing pituitary tumors"
    return b,c

def chest_net(img):
    lt = ['PNEUMONIA', 'NORMAL']
    # img = cv2.resize(img,(224,224))
    model = tf.keras.models.load_model("chest.h5",compile=False)
    result = model.predict(np.array([img]))
    ans = np.argmax(result)
    return lt[ans]

def Eye_net(img):
    lt = ['glaucoma', 'normal', 'diabetic_retinopathy', 'cataract']
    # img = cv2.resize(img,(224,224))
    model = tf.keras.models.load_model("eye.h5",compile=False)
    result = model.predict(np.array([img]))
    ans = np.argmax(result)
    return lt[ans]

def kidney_net(img):
    lt = ['Cyst', 'Tumor', 'Stone', 'Normal']
    # img = cv2.resize(img,(224,224))
    model = tf.keras.models.load_model("kidney.h5",compile=False)
    result = model.predict(np.array([img]))
    ans = np.argmax(result)
    return lt[ans]

def skin_net(img):
    lt = ['pigmented benign keratosis', 'melanoma', 'vascular lesion', 'actinic keratosis', 'squamous cell carcinoma', 'basal cell carcinoma', 'seborrheic keratosis', 'dermatofibroma', 'nevus']
    # img = cv2.resize(img,(224,224))
    model = tf.keras.models.load_model("skin.h5",compile=False)
    result = model.predict(np.array([img]))
    ans = np.argmax(result)
    return lt[ans]