kumar989 commited on
Commit
6d78e3d
·
1 Parent(s): e2faf5f

Update model.py

Browse files
Files changed (1) hide show
  1. model.py +80 -7
model.py CHANGED
@@ -49,7 +49,15 @@ def bone_net(img):
49
  model = tf.keras.models.load_model("fracture.h5",compile=False)
50
  result = model.predict(np.array([img]))
51
  ans = np.argmax(result)
52
- return lt[ans]
 
 
 
 
 
 
 
 
53
 
54
  def brain_net(img):
55
  lt = ['pituitary', 'notumor', 'meningioma', 'glioma']
@@ -63,11 +71,11 @@ def brain_net(img):
63
  b = f"Glioma: Can range from low-grade (mild) to high-grade (severe)."
64
  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."
65
  if ans==2:
66
- b=f"Meningioma: Most are low-grade."
67
  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."
68
  if ans==1:
69
  b = "No tumor: N/A \n\n Enjoy the Life "
70
- c = ""
71
  if ans==0:
72
  b = f"Pituitary: Can be either benign or malignant."
73
  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"
@@ -79,15 +87,37 @@ def chest_net(img):
79
  model = tf.keras.models.load_model("chest.h5",compile=False)
80
  result = model.predict(np.array([img]))
81
  ans = np.argmax(result)
82
- return lt[ans]
 
 
 
 
 
 
 
 
83
 
84
  def Eye_net(img):
85
  lt = ['glaucoma', 'normal', 'diabetic_retinopathy', 'cataract']
86
  # img = cv2.resize(img,(224,224))
87
  model = tf.keras.models.load_model("eye.h5",compile=False)
88
  result = model.predict(np.array([img]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  ans = np.argmax(result)
90
- return lt[ans]
91
 
92
  def kidney_net(img):
93
  lt = ['Cyst', 'Tumor', 'Stone', 'Normal']
@@ -95,7 +125,21 @@ def kidney_net(img):
95
  model = tf.keras.models.load_model("kidney.h5",compile=False)
96
  result = model.predict(np.array([img]))
97
  ans = np.argmax(result)
98
- return lt[ans]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  def skin_net(img):
101
  lt = ['pigmented benign keratosis', 'melanoma', 'vascular lesion', 'actinic keratosis', 'squamous cell carcinoma', 'basal cell carcinoma', 'seborrheic keratosis', 'dermatofibroma', 'nevus']
@@ -103,4 +147,33 @@ def skin_net(img):
103
  model = tf.keras.models.load_model("skin.h5",compile=False)
104
  result = model.predict(np.array([img]))
105
  ans = np.argmax(result)
106
- return lt[ans]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  model = tf.keras.models.load_model("fracture.h5",compile=False)
50
  result = model.predict(np.array([img]))
51
  ans = np.argmax(result)
52
+ a=""
53
+ b=""
54
+ if ans==0:
55
+ a="Normal "
56
+ b="There is no bone facture detected"
57
+ if ans==1:
58
+ a="Fractured"
59
+ b="There is bone facture.\nconsult doctor Immediately\nApply ice: Apply ice to the affected area to reduce swelling and pain. Wrap the ice in a cloth or towel and apply it to the area for 15-20 minutes at a time, several times a day."
60
+ return a,b
61
 
62
  def brain_net(img):
63
  lt = ['pituitary', 'notumor', 'meningioma', 'glioma']
 
71
  b = f"Glioma: Can range from low-grade (mild) to high-grade (severe)."
72
  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."
73
  if ans==2:
74
+ b = f"Meningioma: Most are low-grade."
75
  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."
76
  if ans==1:
77
  b = "No tumor: N/A \n\n Enjoy the Life "
78
+ c = "No Tumor has been detected \n Follow the precautions be healthy"
79
  if ans==0:
80
  b = f"Pituitary: Can be either benign or malignant."
81
  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"
 
87
  model = tf.keras.models.load_model("chest.h5",compile=False)
88
  result = model.predict(np.array([img]))
89
  ans = np.argmax(result)
90
+ d=""
91
+ e=""
92
+ if ans==0:
93
+ d=f" Might be you are effected by pneumonia "
94
+ e=f"Vaccination is the best protection against pneumonia."
95
+ if ans==1:
96
+ d=f"Normal"
97
+ e=f"Practice good hygiene by washing your hands frequently and avoiding touching your face"
98
+ return d,e
99
 
100
  def Eye_net(img):
101
  lt = ['glaucoma', 'normal', 'diabetic_retinopathy', 'cataract']
102
  # img = cv2.resize(img,(224,224))
103
  model = tf.keras.models.load_model("eye.h5",compile=False)
104
  result = model.predict(np.array([img]))
105
+ f=""
106
+ g=""
107
+ if ans==3:
108
+ f=f"You are Effected by Cataract"
109
+ g=f'Protect your eyes from harmful UV rays with sunglasses or a hat.'
110
+ if ans==2:
111
+ f=f"Diaetic Retinopathy"
112
+ g='Control your blood sugar levels to prevent diabetic retinopathy.'
113
+ if ans==1:
114
+ f=f"normal CONDITION"
115
+ g='You are in Normal condition , Maintain same '
116
+ if ans==0:
117
+ f=f'glaucoma detected'
118
+ g="Follow your doctor's instructions for taking glaucoma medications."
119
  ans = np.argmax(result)
120
+ return f,g
121
 
122
  def kidney_net(img):
123
  lt = ['Cyst', 'Tumor', 'Stone', 'Normal']
 
125
  model = tf.keras.models.load_model("kidney.h5",compile=False)
126
  result = model.predict(np.array([img]))
127
  ans = np.argmax(result)
128
+ h=""
129
+ i=""
130
+ if ans==0:
131
+ h="Cyst"
132
+ i="Avoid drinking alcohol, as it can irritate the kidneys and cause cysts to form.\nMaintain a healthy weight to reduce the risk of developing cysts."
133
+ if ans==1:
134
+ h="Tumor"
135
+ i="Quit smoking to reduce the risk of kidney tumors.\nMaintain a healthy diet, rich in fruits and vegetables, to prevent the development of tumors.\nStay physically active to reduce the risk of developing tumors."
136
+ if ans==2:
137
+ h="Stone"
138
+ i="Drink plenty of water to prevent the formation of kidney stones.\nLimit your intake of salt and animal protein to reduce the risk of developing stones.\nEat a diet rich in fruits and vegetables to prevent the formation of stones."
139
+ if ans==3:
140
+ h="Normal"
141
+ i="You are in Normal Condition\n Be safe"
142
+ return h,i
143
 
144
  def skin_net(img):
145
  lt = ['pigmented benign keratosis', 'melanoma', 'vascular lesion', 'actinic keratosis', 'squamous cell carcinoma', 'basal cell carcinoma', 'seborrheic keratosis', 'dermatofibroma', 'nevus']
 
147
  model = tf.keras.models.load_model("skin.h5",compile=False)
148
  result = model.predict(np.array([img]))
149
  ans = np.argmax(result)
150
+ l=""
151
+ m=""
152
+ if ans==0:
153
+ l="pigmented benign keratosis"
154
+ m="Protect your eyes from excessive exposure to sunlight or other sources of UV radiation.\nAvoid rubbing or scratching the affected area to prevent irritation or injury."
155
+ if ans==1:
156
+ l="melanoma"
157
+ m="Regular eye exams with a qualified healthcare professional can help detect early signs of melanoma in the eye.\nWearing UV-protective eyewear and avoiding prolonged exposure to sunlight can help reduce the risk of developing melanoma in the eye."
158
+ if ans==2:
159
+ l="vascular lesion"
160
+ m="Vascular lesions in the eye can be fragile and prone to bleeding, so it is important to avoid any activities that can increase intraocular pressure, such as heavy lifting or straining."
161
+ if ans==3:
162
+ l="actinic keratosis"
163
+ m="Protect your eyes from UV radiation by wearing UV-blocking sunglasses or a hat with a brim.\nAvoid prolonged exposure to sunlight, especially during peak hours when the sun's rays are strongest."
164
+ if ans==4:
165
+ l="squamous cell carcinoma"
166
+ m="Avoid smoking and limit alcohol consumption as they increase the risk of developing squamous cell carcinoma in the eye."
167
+ if ans==5:
168
+ l="basal cell carcinoma"
169
+ m="Wear protective eyewear.\nMonitor your skin for any changes or abnormalities."
170
+ if ans==6:
171
+ l="seborrheic keratosis"
172
+ m="Seborrheic keratosis near the eye should be examined by a healthcare professional to rule out the possibility of malignant growth.\nAvoid rubbing or scratching the affected area around the eye to prevent irritation or injury."
173
+ if ans==7:
174
+ l="dermatofibroma"
175
+ m="Avoid scratching or picking at the dermatofibroma to prevent infection and further irritation.\nProtect the dermatofibroma from direct sunlight or excessive heat exposure to prevent discoloration or changes in texture."
176
+ if ans==8:
177
+ l="nevus"
178
+ m="Regularly monitor the nevus and report any changes to your healthcare provider.\nProtect your eyes from excessive sun exposure by wearing sunglasses and a hat with a brim."
179
+ return l,m