Spaces:
Runtime error
Runtime error
cybernatedArt
commited on
Commit
·
d1371b6
1
Parent(s):
d7119c4
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,87 @@
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
import tensorflow as tf
|
5 |
+
from tensorflow import keras
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
+
import tensorflow_hub as hub
|
8 |
|
9 |
+
hide_streamlit_style = """
|
10 |
+
<style>
|
11 |
+
#MainMenu {visibility: hidden;}
|
12 |
+
footer {visibility: hidden;}
|
13 |
+
</style>
|
14 |
+
"""
|
15 |
+
|
16 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html = True)
|
17 |
|
18 |
+
st.title('SKIN DISEASE PREDICTION')
|
19 |
+
st.write("An automated system is proposed for the diagnosis of #23 common skin diseases by using data from clinical images and patient information.")
|
20 |
|
21 |
+
def main() :
|
22 |
+
file_uploaded = st.file_uploader('Choose an image...', type = 'jpg')
|
23 |
+
if file_uploaded is not None :
|
24 |
+
image = Image.open(file_uploaded)
|
25 |
+
st.write("Uploaded Image.")
|
26 |
+
figure = plt.figure()
|
27 |
+
plt.imshow(image)
|
28 |
+
plt.axis('off')
|
29 |
+
st.pyplot(figure)
|
30 |
+
result, confidence = predict_class(image)
|
31 |
+
st.write('Prediction : {}'.format(result))
|
32 |
+
st.write('Confidence : {}%'.format(confidence))
|
33 |
|
34 |
+
def predict_class(image) :
|
35 |
+
with st.spinner('Loading Model...'):
|
36 |
+
classifier_model = keras.models.load_model(r'model_2.h5', compile = False)
|
37 |
|
38 |
+
shape = ((256,256,3))
|
39 |
+
model = keras.Sequential([hub.KerasLayer(classifier_model, input_shape = shape)]) # ye bhi kaam kar raha he
|
40 |
+
test_image = image.resize((256, 256))
|
41 |
+
test_image = keras.preprocessing.image.img_to_array(test_image)
|
42 |
+
test_image /= 256.0
|
43 |
+
test_image = np.expand_dims(test_image, axis = 0)
|
44 |
+
class_name = ['Acne and Rosacea Photos',
|
45 |
+
'Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions',
|
46 |
+
'Atopic Dermatitis Photos', 'Bullous Disease Photos', 'Cellulitis Impetigo and other Bacterial Infections',
|
47 |
+
'Eczema Photos', 'Exanthems and Drug Eruptions', 'Hair Loss Photos Alopecia and other Hair Diseases',
|
48 |
+
'Herpes HPV and other STDs Photos', 'Light Diseases and Disorders of Pigmentation', 'Lupus and other Connective Tissue diseases',
|
49 |
+
'Melanoma Skin Cancer Nevi and Moles', 'Nail Fungus and other Nail Disease', 'Poison Ivy Photos and other Contact Dermatitis',
|
50 |
+
'Psoriasis pictures Lichen Planus and related diseases', 'Scabies Lyme Disease and other Infestations and Bites',
|
51 |
+
'Seborrheic Keratoses and other Benign Tumors', 'Systemic Disease', 'Tinea Ringworm Candidiasis and other Fungal Infections',
|
52 |
+
'Urticaria Hives', 'Vascular Tumors', 'Vasculitis Photos', 'Warts Molluscum and other Viral Infections']
|
53 |
+
prediction = model.predict_generator(test_image)
|
54 |
+
confidence = round(100 * (np.max(prediction[0])), 2)
|
55 |
+
final_pred = class_name[np.argmax(prediction)]
|
56 |
+
return final_pred, confidence
|
57 |
|
58 |
+
footer = """
|
59 |
+
<style>
|
60 |
+
a:link , a:visited{
|
61 |
+
color: white;
|
62 |
+
background-color: transparent;
|
63 |
+
text-decoration: None;
|
64 |
+
}
|
65 |
+
a:hover, a:active {
|
66 |
+
color: red;
|
67 |
+
background-color: transparent;
|
68 |
+
text-decoration: None;
|
69 |
+
}
|
70 |
+
.footer {
|
71 |
+
position: fixed;
|
72 |
+
left: 0;
|
73 |
+
bottom: 0;
|
74 |
+
width: 100%;
|
75 |
+
background-color: transparent;
|
76 |
+
color: black;
|
77 |
+
text-align: center;
|
78 |
+
}
|
79 |
+
<div class="footer">
|
80 |
+
<p align="center"> Developed with ❤ by Mato</p>
|
81 |
+
</div>
|
82 |
+
</style>
|
83 |
+
"""
|
84 |
+
st.markdown(footer, unsafe_allow_html = True)
|
85 |
+
if __name__ == "__main__":
|
86 |
+
main()
|
87 |
+
|