crossdevlogix commited on
Commit
178b852
·
verified ·
1 Parent(s): e6f0273

Upload 6 files

Browse files
Chicken_Heart_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d783c67e3831d9f027248cdabec0463807c16871692e4cd6100a6e0d1341b012
3
+ size 220570576
Liver_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f6e5ec33701c39f01880a39cc234b91f7d65c5655225513dcf8df4cc312a055
3
+ size 234256912
Lungs_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89b45715139e7df3c2342d82f626eb1c6b49357ecff5ddf839492da603ad5648
3
+ size 234256912
app.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from keras.models import load_model
2
+ import cv2
3
+ from tensorflow.keras.preprocessing.image import ImageDataGenerator
4
+ import gradio as gr
5
+ import numpy as np
6
+
7
+
8
+ my_model=load_model('Liver_model.h5',compile=True)
9
+ heart_model=load_model('Chicken_Heart_model.h5',compile=True)
10
+ lu_model=load_model('Lungs_model.h5',compile=True)
11
+ auth_model=load_model('post_auth_model.h5',compile=True)
12
+ heart_class_name={0:'Dilation(eccentric)',1:'Hepatoma',2:'Hypertrophy(concentric)',3:'Hypertrophy(physiological)',4:'Infraction Damage',5:'Normal'}
13
+ heart_result={0:'Critical',1:'Critical',2:'Critical',3:'Critical',4:'Critical',5:'Normal'}
14
+ heart_recommend={0:'panadol',1:'peracetamol',2:'ponston',4:'brofon',5:'No Need'}
15
+
16
+ def Heart_Disease_prediction(img):
17
+ img = img.reshape((1, img.shape[0], img.shape[1], img.shape[2]))
18
+
19
+ # Create the data generator with desired properties
20
+ datagen = ImageDataGenerator(
21
+ rotation_range=30,
22
+ width_shift_range=0.1,
23
+ height_shift_range=0.1,
24
+ shear_range=0.1,
25
+ zoom_range=0.1,
26
+ horizontal_flip=True,
27
+ fill_mode="nearest",
28
+ )
29
+ # Generate a batch of augmented images (contains only the single image)
30
+ augmented_images = datagen.flow(img, batch_size=1)
31
+ # Get the first (and only) augmented image from the batch
32
+ augmented_img = next(augmented_images)[0]
33
+ img=cv2.resize(augmented_img.astype(np.uint8),(128,128))
34
+ class_no=heart_model.predict(img.reshape(1,128,128,3)).argmax()
35
+ name="Heart Disease Class Name: "+""+heart_class_name.get(class_no)
36
+ result="Heart Disease result: "+""+heart_result.get(class_no)
37
+ recommend="Heart Medicine Recommend: "+""+heart_recommend.get(class_no)
38
+ return name,result,recommend
39
+
40
+ liver_class_num={0:'Healthy',1:'Un-Healthy'}
41
+ liver_result={0:'Normal',1:'Critical'}
42
+ liver_recommend={0:'No need Medicine',1:'Panadol'}
43
+ def Liver_Predict(Image):
44
+ Image=cv2.resize(Image,(224,224))
45
+ class_no=my_model.predict(Image.reshape(1,224,224,3)).argmax()
46
+ class_name="Liver Class Name: "+""+liver_class_num.get(class_no)
47
+ liver_class_result="Liver Class Result: "+""+liver_result.get(class_no)
48
+ liver_class_recommend="Liver Class Recommend: "+""+liver_recommend.get(class_no)
49
+ return class_name,liver_class_result,liver_class_recommend
50
+
51
+
52
+
53
+ lung_classes={0:'Lungs of infected chickens showing congestion, hemorrhage and consolidation with traces of fibrin at 24 hpi (hours post-infection)',
54
+ 1:'gradual paleness and reduction in size of lungs at 2 dpi (days post-infection)',
55
+ 2:'gradual paleness and reduction in size of lung at 3 dpi (days post-infection)',
56
+ 3:'severe congestion, hemorrhage, and gradual shrinking of lungs at 4 dpi (days post-infection)',
57
+ 4:'severe congestion, hemorrhage, and gradual shrinking of lungs at 5 dpi (days post-infection)'}
58
+ lung_result={0:'critical',1:'critical',2:'critical',3:'critical',4:'critical'}
59
+ lung_recommend={0:'panadol',1:'peracetamol',2:'ponston',4:'brofon'}
60
+
61
+ def Lungs_predict(image):
62
+ image=cv2.resize(image,(224,224))
63
+ lung_no=lu_model.predict(image.reshape(1,224,224,3)).argmax()
64
+ lung_disease_name="Lung Disease Name: "+""+lung_classes.get(lung_no)
65
+ lung_r="Lung result: "+""+lung_result.get(lung_no)
66
+ lung_re="Lung recommendation: "+""+lung_recommend.get(lung_no)
67
+ return lung_disease_name,lung_r,lung_re
68
+
69
+
70
+ def main(Image):
71
+ img=cv2.resize(Image,(224,224))
72
+ indx=auth_model.predict(img.reshape(1,224,224,3)).argmax()
73
+ if indx==0:
74
+ Name='Unkown'
75
+ result='N/A'
76
+ recommend='N/A'
77
+ return Name,result,recommend,Name,result,recommend,Name,result,recommend
78
+ else:
79
+ heart_n,heart_r,heart_re=Heart_Disease_prediction(Image)
80
+ liver_name,liver_r,liver_re=Liver_Predict(Image)
81
+ lung_d,lung_r,lung_re=Lungs_predict(Image)
82
+ return heart_n,heart_r,heart_re,liver_name,liver_r,liver_re,lung_d,lung_r,lung_re
83
+
84
+ interface=gr.Interface(fn=main,inputs='image',outputs=[gr.components.Textbox(label="Heart Disease Name"),gr.components.Textbox(label="Heart result Name"),gr.components.Textbox(label="Heart recommend"),
85
+ gr.components.Textbox(label="Liver Disease Name"),gr.components.Textbox(label="liver result Name"),gr.components.Textbox(label="Liver recommend"),
86
+ gr.components.Textbox(label="Lung Disease Name"),gr.components.Textbox(label="Lung result Name"),gr.components.Textbox(label="Lung recommend")],
87
+ title="Postmortem")
88
+ interface.launch(debug=True)
89
+
post_auth_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cf43deb182f86f93d0fd9d37ae27638c40c31038442538c6f378d164bb0d6ec
3
+ size 215440896
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ tensorflow==2.12.0
2
+ keras
3
+ opencv-python