-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
140 lines (88 loc) · 3.23 KB
/
app.py
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import streamlit as st
import numpy as np
import requests
from streamlit_lottie import st_lottie
import streamlit.components.v1 as components
import tensorflow as tf
from tensorflow import keras
#### Loading Model
model = keras.models.load_model('models/{1}')
#### Predicting
def predict(img,model):
image = tf.keras.preprocessing.image.load_img(img)
input_arr = tf.keras.preprocessing.image.img_to_array(image)
input_arr = np.array([input_arr]) # Convert single image to a batch.
predictions = model.predict(input_arr)
if predictions[0]>0.5:
return 1
else:
return 0
### Loading Lottie Animation
def load_lottieurl(url):
r = requests.get(url)
if r.status_code != 200:
return None
return r.json()
lottie_coding=load_lottieurl("https://assets9.lottiefiles.com/private_files/lf30_lX3vm6.json")
#### Introdcution Section
with st.container():
components.html("""
<div >
<h1 style="text-align:center;color:white;font-family:monospace;font-size:50px;">
Malaria Detection
</h1>
</div
""")
left_column,right_column=st.columns([3,2])
with left_column:
st.subheader("What is Malaria ?")
st.write("""
Malaria is a disease caused by a parasite. The parasite is spread to humans through the bites of infected mosquitoes. People who have malaria usually feel very sick with a high fever and shaking chills
""")
st.subheader("How is Prediction helps?")
st.write("""
User can save humans by detecting and deploying Image Cells that contain Malaria or not!
""")
with right_column:
st_lottie(lottie_coding,height=300,key="air pollution")
st.write("---")
### Hiding Streamlit Watermarks
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
### Middle Sub Section
st.subheader("Give a Image of Cell for Prediction")
file=st.file_uploader("Please Upload an Image ",type=['jpg','png'])
if file is None:
st.text("Please upload an valid image file ")
else:
ans=predict(file,model)
image1 = tf.keras.preprocessing.image.load_img(file)
st.image(image1,width=300)#use_column_width=True)
if ans==0:
st.success(" Oh ! This cell is Infected with Malaria ")
else:
st.success(" The cell is not Infected with Malaria ")
st.write("---")
# Showing Some Images of Parasitized and Uninfected
with st.container():
st.header("Difference between Infected and Uninfected")
st.markdown(""" """)
st.markdown(""" """)
left_column,right_column=st.columns([1,1])
with left_column:
st.subheader("Uninfected")
st.markdown(""" """)
st.image("uninfected.png")
with right_column:
st.subheader("Parasitized")
st.markdown(""" """)
st.image("Parasitized.png")
st.write("---")
st.write("Credits")
st.markdown(""" Dataset taken from Kaggle : [Link Here](https://www.kaggle.com/datasets/iarunava/cell-images-for-detecting-malaria) """)
st.write("You can Download Here More Images for Checking")