ff98 commited on
Commit
43511ce
·
1 Parent(s): 7ac4458

interface updated

Browse files
Files changed (3) hide show
  1. Models/Final_CNN_Model.ipynb +3 -11
  2. app.py +24 -4
  3. styles/style.css +7 -1
Models/Final_CNN_Model.ipynb CHANGED
@@ -52,7 +52,7 @@
52
  },
53
  {
54
  "cell_type": "code",
55
- "execution_count": 10,
56
  "id": "ba44c3f6-6cdc-4043-ac1e-a062232c8385",
57
  "metadata": {},
58
  "outputs": [],
@@ -62,18 +62,10 @@
62
  },
63
  {
64
  "cell_type": "code",
65
- "execution_count": 11,
66
  "id": "7935d153-6582-42e9-915b-9bc2812923a4",
67
  "metadata": {},
68
- "outputs": [
69
- {
70
- "name": "stdout",
71
- "output_type": "stream",
72
- "text": [
73
- "Found 78528 images belonging to 2 classes.\n"
74
- ]
75
- }
76
- ],
77
  "source": [
78
  "# Now we will preprocess data using the method from ImageDataGen. class flow_from_directory\n",
79
  "\n",
 
52
  },
53
  {
54
  "cell_type": "code",
55
+ "execution_count": 3,
56
  "id": "ba44c3f6-6cdc-4043-ac1e-a062232c8385",
57
  "metadata": {},
58
  "outputs": [],
 
62
  },
63
  {
64
  "cell_type": "code",
65
+ "execution_count": null,
66
  "id": "7935d153-6582-42e9-915b-9bc2812923a4",
67
  "metadata": {},
68
+ "outputs": [],
 
 
 
 
 
 
 
 
69
  "source": [
70
  "# Now we will preprocess data using the method from ImageDataGen. class flow_from_directory\n",
71
  "\n",
app.py CHANGED
@@ -127,8 +127,27 @@ st.markdown(
127
  """<p class = "upload_line"> Please upload the image </p>""",
128
  unsafe_allow_html= True
129
  )
 
 
 
 
 
 
 
130
  user_image = st.file_uploader("png, jpg, or jpeg image", ['png', 'jpg', 'jpeg'], label_visibility='hidden')
131
- model_name = st.selectbox('Choose a model', ['CNN', 'Efficiencynet', 'Efficiencynet Art'], index=None, placeholder='choose an option')
 
 
 
 
 
 
 
 
 
 
 
 
132
  result_placeholder = st.empty()
133
 
134
  # design animation elements
@@ -158,10 +177,10 @@ if user_image is not None and model_name is not None:
158
  if model_name == 'CNN':
159
  print('CNN is running')
160
  predictions = pre_process_img(user_image)
161
- elif model_name == 'Efficiencynet':
162
  print('Effnet is running')
163
  predictions = pre_process_img_effNet(user_image)
164
- elif model_name == 'Efficiencynet Art':
165
  print('Effnet Art is running')
166
  predictions = pre_process_img_effNetArt(user_image)
167
 
@@ -172,7 +191,8 @@ if user_image is not None and model_name is not None:
172
 
173
  if user_image is not None:
174
  if len(predictions) > 0:
175
- result_placeholder.markdown(f"<div class='result'> It is a <span class = resultword> {result_word} </span> image </div>", unsafe_allow_html=True)
 
176
 
177
  print(model_name)
178
  print(predictions[0])
 
127
  """<p class = "upload_line"> Please upload the image </p>""",
128
  unsafe_allow_html= True
129
  )
130
+
131
+ # introduce states
132
+ if "prev_image" not in st.session_state:
133
+ st.session_state.prev_image = None
134
+ if "model_key" not in st.session_state:
135
+ st.session_state.model_key = "default_model_key"
136
+
137
  user_image = st.file_uploader("png, jpg, or jpeg image", ['png', 'jpg', 'jpeg'], label_visibility='hidden')
138
+ if user_image != st.session_state.prev_image:
139
+ if st.session_state.prev_image is not None:
140
+ st.session_state.model_key = "reset_model_key" # reset after the first upload
141
+ st.session_state.prev_image = user_image # set prev image to current image
142
+
143
+ model_name = st.selectbox(
144
+ 'Choose a model',
145
+ ['CNN', 'Efficientnet', 'Efficientnet Art'],
146
+ index=None,
147
+ placeholder='choose an option',
148
+ key=st.session_state.model_key
149
+ )
150
+ print("model name is ", model_name)
151
  result_placeholder = st.empty()
152
 
153
  # design animation elements
 
177
  if model_name == 'CNN':
178
  print('CNN is running')
179
  predictions = pre_process_img(user_image)
180
+ elif model_name == 'Efficientnet':
181
  print('Effnet is running')
182
  predictions = pre_process_img_effNet(user_image)
183
+ elif model_name == 'Efficientnet Art':
184
  print('Effnet Art is running')
185
  predictions = pre_process_img_effNetArt(user_image)
186
 
 
191
 
192
  if user_image is not None:
193
  if len(predictions) > 0:
194
+ result_placeholder.markdown(f"<div class='result'> <span class = 'prediction'>Prediction: {predictions[0][0]}</span> <br> It is a <span class = resultword> {result_word} </span> image. </div>", unsafe_allow_html=True)
195
+
196
 
197
  print(model_name)
198
  print(predictions[0])
styles/style.css CHANGED
@@ -94,6 +94,12 @@ body {
94
  font-size: 32px;
95
  }
96
 
 
 
 
 
 
 
97
  @keyframes textclip {
98
  to {
99
  background-position: 200% center;
@@ -170,7 +176,7 @@ body {
170
  }
171
  }
172
 
173
- @media (max-width: 360px) {
174
  .detectiveMag1,
175
  .detectiveMag2,
176
  .detectiveMag3 {
 
94
  font-size: 32px;
95
  }
96
 
97
+ .prediction {
98
+ padding-top: 0 !important;
99
+ margin-top: 0 !important;
100
+ font-size: 14px;
101
+ }
102
+
103
  @keyframes textclip {
104
  to {
105
  background-position: 200% center;
 
176
  }
177
  }
178
 
179
+ @media (max-width: 390px) {
180
  .detectiveMag1,
181
  .detectiveMag2,
182
  .detectiveMag3 {