-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
96 lines (80 loc) · 2.75 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
from distutils.command.upload import upload
from statistics import mode
from unittest.main import MAIN_EXAMPLES
import streamlit as st
from streamlit_option_menu import option_menu
from front.home import home
from front.upload_photo import upload_photo
# Tensorflow
import os
import tensorflow.keras.models as tfkm
st.markdown("""
<style>
body {
background-color: #ffbc00;
}
</style>
""", unsafe_allow_html=True)
'''
# Cheetah Melanoma Detection
'''
MAIN_MENU = "Cheetah"
HOME = "DermaDashboard"
TEST_PHOTO = "Select from test photos"
UPLOAD_PHOTO = "Get Priority"
SETTINGS = "Settings"
@st.cache(allow_output_mutation=True)
def load_models():
print("loading models: ")
model_bin_96 = tfkm.load_model('models/ResNet50_finetuned_20220620_134553.h5')
# model_bin_96 = tfkm.load_model('models/ResNet50_finetuned_20220621_191452.h5') #version Abdiel
print("Binary model loaded.")
model_cat_84 = tfkm.load_model('models/ResNet50_multiclass_20220623_121940.h5')
# model_cat_84 = tfkm.load_model('models/models_ResNet50_multiclass_20220623_121940.h5') #version Abdiel
print("Categorical model loaded.")
return model_bin_96, model_cat_84
#pre trained models to do predictions
model_binary, model_categorical = load_models()
# 1. as sidebar menu
with st.sidebar:
selected = option_menu(MAIN_MENU, [UPLOAD_PHOTO, HOME],
icons=[ 'cloud-upload', 'house'], menu_icon="", default_index=0)
print(selected)
if selected==HOME:
home()
elif selected==UPLOAD_PHOTO:
upload_photo(model_binary, model_categorical)
# 2. horizontal menu
# selected2 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
# icons=['house', 'cloud-upload', "list-task", 'gear'],
# menu_icon="cast", default_index=0, orientation="horizontal")
# selected2
# 3. CSS style definitions
#selected3 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
# icons=['house', 'cloud-upload', "list-task", 'gear'],
# menu_icon="cast", default_index=0, orientation="horizontal",
# styles={
# "container": {"padding": "0!important", "background-color": "#fafafa"},
# "icon": {"color": "orange", "font-size": "25px"},
# "nav-link": {"font-size": "25px", "text-align": "left", "margin":"0px", "--hover-color": "#eee"},
# "nav-link-selected": {"background-color": "green"},
# }
#)
#st.markdown('''
#This is the first iteration of the front end
#''')
#
#'''
### Here we would like to add some controllers in order to ask the user to test either a test image either upload it's own dermatoscopic image
#
#
### Once we have these, let's call our API in order to retrieve a prediction
#
#'''
#
#
#url = '<insert here the url of the API in order to predcit with the model'
#
#'''
### Finally, we can display the prediction to the user
#'''