File size: 14,101 Bytes
a3a53e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import pickle
import numpy as np
import streamlit as st
from tensorflow.keras.models import load_model

def load_essential_models(scaler_6_path, scaler_8_path, scaler_full_path, clf_6_path, clf_8_path, clf_full_path):
    scaler_6 = pickle.load(open(file=scaler_6_path, mode='rb'))
    scaler_8 = pickle.load(open(file=scaler_8_path, mode='rb'))
    scaler_21 = pickle.load(open(file=scaler_full_path, mode='rb'))
    clf_6 = pickle.load(open(file=clf_6_path, mode='rb'))
    clf_8 = load_model(clf_8_path)
    clf_21 = load_model(clf_full_path)
    return scaler_6, scaler_8, scaler_21, clf_6, clf_8, clf_21

scaler_6, scaler_8, scaler_21, clf_6, clf_8, clf_21 = load_essential_models(scaler_6_path='./Models/6/scaler.pkl', scaler_8_path='./Models/8/scaler.pkl', scaler_full_path='./Models/21/scaler.pkl', clf_6_path='./Models/6/svc_fs_tune.pkl', clf_8_path='./Models/8/ANNs_8base.h5', clf_full_path='./Models/21/ANNs_full.h5')

st.title('Demo System for Vietnamese Woman Bra Size Classifier')

header_col_1, header_col_2 = st.columns([3, 2])
num_of_features = header_col_1.selectbox(label='Please select the number of measurements you have:', options=['6 measurements', '8 measurements', '21 measurements'])

h, w, bmi, vtn, vn, vcn, cn, cnnp, cnnt, cntp, cntt, ccnp, ccnt, snt, sndp, sndt, xup, xut, cl, ttp, ttt = [0.0]*21

if num_of_features == '6 measurements':
    sample_options_6 = header_col_2.selectbox(label='Sample options:', options=['Sample 1 (Small)', 'Sample 2 (Medium)', 'Sample 3 (Large)'])
    container_col_1, container_col_2, container_col_3 = st.columns([1, 1, 1])
    if sample_options_6 == 'Sample 1 (Small)':
        vtn = container_col_1.number_input(label='Your vtn: ', value=82.00, min_value=0.00, step=0.01)
        vn = container_col_2.number_input(label='Your vn:', value=82.40, min_value=0.00, step=0.01)
        vcn = container_col_3.number_input(label='Your vcn:', value=73.10, min_value=0.00, step=0.01)
        cl = container_col_1.number_input(label='Your cl:', value=9.30, min_value=0.00, step=0.01)
        ttp = container_col_2.number_input(label='Your ttp:', value=325.6, min_value=0.00, step=0.01)
        ttt = container_col_3.number_input(label='Your ttt:', value=325.6, min_value=0.00, step=0.01)
    elif sample_options_6 == 'Sample 2 (Medium)':
        vtn = container_col_1.number_input(label='Your vtn: ', value=77.20, min_value=0.00, step=0.01)
        vn = container_col_2.number_input(label='Your vn:', value=78.60, min_value=0.00, step=0.01)
        vcn = container_col_3.number_input(label='Your vcn:', value=66.50, min_value=0.00, step=0.01)
        cl = container_col_1.number_input(label='Your cl:', value=12.10, min_value=0.00, step=0.01)
        ttp = container_col_2.number_input(label='Your ttp:', value=388.80, min_value=0.00, step=0.01)
        ttt = container_col_3.number_input(label='Your ttt:', value=324.60, min_value=0.00, step=0.01)
    else:
        vtn = container_col_1.number_input(label='Your vtn: ', value=86.50, min_value=0.00, step=0.01)
        vn = container_col_2.number_input(label='Your vn:', value=88.00, min_value=0.00, step=0.01)
        vcn = container_col_3.number_input(label='Your vcn:', value=74.00, min_value=0.00, step=0.01)
        cl = container_col_1.number_input(label='Your cl:', value=14.00, min_value=0.00, step=0.01)
        ttp = container_col_2.number_input(label='Your ttp:', value=451.30, min_value=0.00, step=0.01)
        ttt = container_col_3.number_input(label='Your ttt:', value=471.60, min_value=0.00, step=0.01)

elif num_of_features == '8 measurements':
    sample_options_8 = header_col_2.selectbox(label='Sample options:', options=['Sample 1 (Small)', 'Sample 2 (Medium)', 'Sample 3 (Large)'])
    container_col_1, container_col_2, container_col_3, container_col_4 = st.columns([1, 1, 1, 1])
    if sample_options_8 == 'Sample 1 (Small)':
        ttp = container_col_1.number_input(label='Your ttp:', value=325.10, min_value=0.00, step=0.01)
        cl = container_col_2.number_input(label='Your cl:', value=8.90, min_value=0.00, step=0.01)
        cnnp = container_col_3.number_input(label='Your cnnp:', value=12.30, min_value=0.00, step=0.01)
        vn = container_col_4.number_input(label='Your vn:', value=83.20, min_value=0.00, step=0.01)
        vtn = container_col_1.number_input(label='Your vtn: ', value=80.10, min_value=0.00, step=0.01)
        ccnt = container_col_2.number_input(label='Your ccnt:', value=11.10, min_value=0.00, step=0.01)
        cntp = container_col_3.number_input(label='Your cntp:', value=8.70, min_value=0.00, step=0.01)
        vcn = container_col_4.number_input(label='Your vcn:', value=74.30, min_value=0.00, step=0.01)
    elif sample_options_8 == 'Sample 2 (Medium)':
        ttp = container_col_1.number_input(label='Your ttp:', value=385.80, min_value=0.00, step=0.01)
        cl = container_col_2.number_input(label='Your cl:', value=13.60, min_value=0.00, step=0.01)
        cnnp = container_col_3.number_input(label='Your cnnp:', value=8.80, min_value=0.00, step=0.01)
        vn = container_col_4.number_input(label='Your vn:', value=83.20, min_value=0.00, step=0.01)
        vtn = container_col_1.number_input(label='Your vtn: ', value=82.50, min_value=0.00, step=0.01)
        ccnt = container_col_2.number_input(label='Your ccnt:', value=9.30, min_value=0.00, step=0.01)
        cntp = container_col_3.number_input(label='Your cntp:', value=9.10, min_value=0.00, step=0.01)
        vcn = container_col_4.number_input(label='Your vcn:', value=69.60, min_value=0.00, step=0.01)
    else:
        ttp = container_col_1.number_input(label='Your ttp:', value=453.30, min_value=0.00, step=0.01)
        cl = container_col_2.number_input(label='Your cl:', value=13.00, min_value=0.00, step=0.01)
        cnnp = container_col_3.number_input(label='Your cnnp:', value=12.50, min_value=0.00, step=0.01)
        vn = container_col_4.number_input(label='Your vn:', value=85.30, min_value=0.00, step=0.01)
        vtn = container_col_1.number_input(label='Your vtn: ', value=78.50, min_value=0.00, step=0.01)
        ccnt = container_col_2.number_input(label='Your ccnt:', value=12.40, min_value=0.00, step=0.01)
        cntp = container_col_3.number_input(label='Your cntp:', value=10.00, min_value=0.00, step=0.01)
        vcn = container_col_4.number_input(label='Your vcn:', value=72.30, min_value=0.00, step=0.01)
else:
    sample_options_21 = header_col_2.selectbox(label='Sample options:', options=['Sample 1 (Small)', 'Sample 2 (Medium)', 'Sample 3 (Large)'])
    container_col_1, container_col_2, container_col_3, container_col_4, container_col_5 = st.columns([1, 1, 1, 1, 1])
    if sample_options_21 == 'Sample 1 (Small)':
        h = container_col_1.number_input(label='Your h:', value=158.50, min_value=0.00, step=0.01)
        w = container_col_2.number_input(label='Your w:', value=44.00, min_value=0.00, step=0.01)
        bmi = container_col_3.number_input(label='Your bmi:', value=17.50, min_value=0.00, step=0.01)
        vtn = container_col_4.number_input(label='Your vtn: ', value=75.40, min_value=0.00, step=0.01)
        vn = container_col_5.number_input(label='Your vn:', value=81.10, min_value=0.00, step=0.01)
        vcn = container_col_1.number_input(label='Your vcn:', value=74.80, min_value=0.00, step=0.01)
        cn = container_col_2.number_input(label='Your cn:', value=14.50, min_value=0.00, step=0.01)
        cnnp = container_col_3.number_input(label='Your cnnp:', value=13.80, min_value=0.00, step=0.01)
        cnnt = container_col_4.number_input(label='Your cnnt:', value=14.40, min_value=0.00, step=0.01)
        cntp = container_col_5.number_input(label='Your cntp:', value=8.60, min_value=0.00, step=0.01)
        cntt = container_col_1.number_input(label='Your cntt:', value=8.40, min_value=0.00, step=0.01)
        ccnp = container_col_2.number_input(label='Your ccnp:', value=21.50, min_value=0.00, step=0.01)
        ccnt = container_col_3.number_input(label='Your ccnt:', value=21.20, min_value=0.00, step=0.01)
        snt = container_col_4.number_input(label='Your snt:', value=8.90, min_value=0.00, step=0.01)
        sndp = container_col_5.number_input(label='Your sndp:', value=6.50, min_value=0.00, step=0.01)
        sndt = container_col_1.number_input(label='Your sndt:', value=6.50, min_value=0.00, step=0.01)
        xup = container_col_2.number_input(label='Your xup:', value=21.80, min_value=0.00, step=0.01)
        xut = container_col_3.number_input(label='Your xut:', value=21.10, min_value=0.00, step=0.01)
        cl = container_col_4.number_input(label='Your cl:', value=6.30, min_value=0.00, step=0.01)
        ttp = container_col_5.number_input(label='Your ttp:', value=325.10, min_value=0.00, step=0.01)
        ttt = container_col_3.number_input(label='Your ttt:', value=335.70, min_value=0.00, step=0.01)
    elif sample_options_21 == 'Sample 2 (Medium)':
        h = container_col_1.number_input(label='Your h:', value=163.00, min_value=0.00, step=0.01)
        w = container_col_2.number_input(label='Your w:', value=43.00, min_value=0.00, step=0.01)
        bmi = container_col_3.number_input(label='Your bmi:', value=16.20, min_value=0.00, step=0.01)
        vtn = container_col_4.number_input(label='Your vtn: ', value=76.00, min_value=0.00, step=0.01)
        vn = container_col_5.number_input(label='Your vn:', value=79.00, min_value=0.00, step=0.01)
        vcn = container_col_1.number_input(label='Your vcn:', value=64.00, min_value=0.00, step=0.01)
        cn = container_col_2.number_input(label='Your cn:', value=16.50, min_value=0.00, step=0.01)
        cnnp = container_col_3.number_input(label='Your cnnp:', value=13.10, min_value=0.00, step=0.01)
        cnnt = container_col_4.number_input(label='Your cnnt:', value=12.60, min_value=0.00, step=0.01)
        cntp = container_col_5.number_input(label='Your cntp:', value=9.20, min_value=0.00, step=0.01)
        cntt = container_col_1.number_input(label='Your cntt:', value=9.10, min_value=0.00, step=0.01)
        ccnp = container_col_2.number_input(label='Your ccnp:', value=19.80, min_value=0.00, step=0.01)
        ccnt = container_col_3.number_input(label='Your ccnt:', value=18.20, min_value=0.00, step=0.01)
        snt = container_col_4.number_input(label='Your snt:', value=8.40, min_value=0.00, step=0.01)
        sndp = container_col_5.number_input(label='Your sndp:', value=3.50, min_value=0.00, step=0.01)
        sndt = container_col_1.number_input(label='Your sndt:', value=3.70, min_value=0.00, step=0.01)
        xup = container_col_2.number_input(label='Your xup:', value=21.00, min_value=0.00, step=0.01)
        xut = container_col_3.number_input(label='Your xut:', value=20.50, min_value=0.00, step=0.01)
        cl = container_col_4.number_input(label='Your cl:', value=15.00, min_value=0.00, step=0.01)
        ttp = container_col_5.number_input(label='Your ttp:', value=521.60, min_value=0.00, step=0.01)
        ttt = container_col_3.number_input(label='Your ttt:', value=513.50, min_value=0.00, step=0.01)
    else:
        h = container_col_1.number_input(label='Your h:', value=152.00, min_value=0.00, step=0.01)
        w = container_col_2.number_input(label='Your w:', value=46.00, min_value=0.00, step=0.01)
        bmi = container_col_3.number_input(label='Your bmi:', value=19.90, min_value=0.00, step=0.01)
        vtn = container_col_4.number_input(label='Your vtn: ', value=77.50, min_value=0.00, step=0.01)
        vn = container_col_5.number_input(label='Your vn:', value=85.50, min_value=0.00, step=0.01)
        vcn = container_col_1.number_input(label='Your vcn:', value=70.40, min_value=0.00, step=0.01)
        cn = container_col_2.number_input(label='Your cn:', value=18.90, min_value=0.00, step=0.01)
        cnnp = container_col_3.number_input(label='Your cnnp:', value=13.50, min_value=0.00, step=0.01)
        cnnt = container_col_4.number_input(label='Your cnnt:', value=12.50, min_value=0.00, step=0.01)
        cntp = container_col_5.number_input(label='Your cntp:', value=10.30, min_value=0.00, step=0.01)
        cntt = container_col_1.number_input(label='Your cntt:', value=10.50, min_value=0.00, step=0.01)
        ccnp = container_col_2.number_input(label='Your ccnp:', value=20.40, min_value=0.00, step=0.01)
        ccnt = container_col_3.number_input(label='Your ccnt:', value=20.10, min_value=0.00, step=0.01)
        snt = container_col_4.number_input(label='Your snt:', value=8.50, min_value=0.00, step=0.01)
        sndp = container_col_5.number_input(label='Your sndp:', value=5.50, min_value=0.00, step=0.01)
        sndt = container_col_1.number_input(label='Your sndt:', value=4.20, min_value=0.00, step=0.01)
        xup = container_col_2.number_input(label='Your xup:', value=19.50, min_value=0.00, step=0.01)
        xut = container_col_3.number_input(label='Your xut:', value=20.50, min_value=0.00, step=0.01)
        cl = container_col_4.number_input(label='Your cl:', value=15.10, min_value=0.00, step=0.01)
        ttp = container_col_5.number_input(label='Your ttp:', value=625.80, min_value=0.00, step=0.01)
        ttt = container_col_3.number_input(label='Your ttt:', value=585.40, min_value=0.00, step=0.01)

col_1, col_2, col_3, col_4, col_5 = st.columns([1, 1, 1, 1, 1])

with col_3:
    predict = st.button(label='Predict', use_container_width=True)

if predict:
    if num_of_features == '6 measurements':
        X_6 = [[vtn, vn, vcn, cl, ttp, ttt]]
        X_6 = scaler_6.transform(X_6)
        y_6 = clf_6.predict(X_6)
        st.success(f'We recommend you choosing {y_6} size!')
    elif num_of_features == '8 measurements':
        X_8 = [[ttp, cl, cnnp, vn, vtn, cnnt, cntp, vcn]]
        X_8 = scaler_8.transform(X_8)
        y_8 = clf_8.predict(X_8)
        st.success(f'We recommend you choosing {np.argmax(y_8, axis=1)} size!')
    else:
        X_21 = [[h, w, bmi, vtn, vn, vcn, cn, cnnp, cnnt, cntp, cntt, ccnp, ccnt, snt, sndp, sndt, xup, xut, cl, ttp, ttt]]
        X_21 = scaler_21.transform(X_21)
        y_21 = clf_21.predict(X_21)
        st.success(f'We recommend you choosing {np.argmax(y_21, axis=1)} size!')